AMDG Arthur Carlsson wrote:
When I try to use the parse_config_file() function from the program_options library I get a link error saying (built on OS X 10.5):
Undefined symbols: "boost::program_options::basic_parsed_options<char> boost::program_options::parse_config_file<char>(std::basic_istream
&, boost::program_options::options_description const&, bool)", referenced from: _main in main.cc.o ld: symbol(s) not found Taking a closer look at the code I discovered that the function is declared as a template in boost/program_options/parsers.hpp but is defined in boost/libs/program_options/src/parsers.cpp. Is this really valid? I've thought that templated functions need to be defined along with the declaration as the template arguments need to be evaluated at compile time. Or am I missing something?
It is legal to define templates in the source files as long as they are explicitly instantiated, which is what these lines after the definition are for template BOOST_PROGRAM_OPTIONS_DECL basic_parsed_options<char> parse_config_file(std::basic_istream<char>& is, const options_description& desc, bool allow_unregistered); As long as you are linking to the program_options library, it should be fine. In Christ, Steven Watanabe