-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable CXX by default #198
Conversation
https://github.com/stevengj/nlopt/blob/master/doc/docs/NLopt_Installation.md also needs to be updated. Does the Matlab plugin work with the C++ version? The mex file may need to end in |
It's silly not to provide all algorithms by default, c++ compiler are easy to find these days, worst case it can still be disabled Also remove lib suffix
I think cmake has what it takes to link to c++ when nlopt_lib is c++ enabled, but I did not test yet. |
doc/docs/NLopt_Installation.md
Outdated
@@ -142,14 +142,13 @@ Note, however, that if you do this then Guile may not know where to load the `nl | |||
NLopt with C++ algorithms | |||
------------------------- | |||
|
|||
NLopt, as-is, is callable from C, C++, and Fortran, with optional Matlab and GNU Octave plugins (and even installs an `nlopt.hpp` C++ header file to allow you to call it in a more C++ style). By default, it includes only subroutines written in C (or written in Fortran and converted to C), to simplify linking. If you configure with: | |||
NLopt, as-is, is callable from C, C++, and Fortran, with optional Matlab and GNU Octave plugins (and even installs an `nlopt.hpp` C++ header file to allow you to call it in a more C++ style). By default, it includes subroutines written in C (or written in Fortran and converted to C) and as well in C++. If you configure with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"and as well" is redundant, and "in" is misplace. Just say "and C++"
doc/docs/NLopt_Installation.md
Outdated
|
||
The `libnlopt_cxx` has the *same* interface as the ordinary NLopt library, and can *still* be called from ordinary C and Fortran programs. However, to use it you must also *link* with the C++ standard libraries. The easiest way to do this is to link with the C++ linker: compile your source files into `.o` object files, and then call the C++ compiler to link these `.o` files with `-lnlopt_cxx` into your executable program. | ||
The resulting library has the *same* interface as the ordinary NLopt library, and can *still* be called from ordinary C, C++, and Fortran programs. However, to use it doesnt have to *link* with the C++ standard libraries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"However, one no longer has to link with the C++ standard libraries, which can sometimes be convenient for non-C++ programs, and allows libnlopt
to be compatible with multiple C++ compilers simultaneously."
Not having this on by default was never about C++ compilers being hard to find. The problems were:
I'm still a bit worried about the latter — if we merge this, some people's Makefiles may break. |
(It used to be that Matlab only shipped with |
I just tested with matlab; it builds and loads fine, I guess it's fine on windows too at least when using cmake. |
I also updated the doc. |
Why was this closed? |
I thought you were not too found of this change. |
I have mixed feelings, but I’m inclined to think that the pros outweigh the cons nowadays thanks to .so dependencies. |
It's silly not to provide all algorithms by default,
c++ compiler are easy to find these days, worst case it can still be disabled
Also remove lib suffix