Hello,

If I include the C++ header nlopt.hpp (version 2.2.1) in more than one source file, I keep getting "multiple definition" linker (gcc) errors of the form:
In function `nlopt::version(int&, int&, int&)':
nlopt.hpp:567: multiple definition of `nlopt::version(int&, int&, int&)'
nlopt.hpp:567: first defined here.

This is obviously due to the fact that some functions (namely srand, version, version_major, version_minor, version_bugfix, algorithm_name) are defined directly in the header. While the inclusion guards prevent the compiler from including the header multiple times in one compilation unit, the linker cannot handle the resulting multiple definitions.

Perhaps it would be better to either declare these functions inline or to define them in a separate source file?

Best regards,
Peter

_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to