
Hi all,
In case anyone is still interested... With the release of Boost 1.41 I
looked into this problem again and found out it was my own mistake.
When linking to a DLL of boost_program_options (in my case without
autolinking), I got two unresolved symbols to the following "global"
variables:
boost::options_description::m_default_line_length and
boost::program_options::arg
The problem was in my CMakeLists.txt file, where I assumed that
setting Boost_USE_STATIC_LIBS to Off would be sufficient. In that case
BOOST_ALL_DYN_LINK is not defined. As a consequence the definition of
BOOST_PROGRAM_OPTIONS_DECL was empty when importing the library, hence
no __declspec( dllimport ) and correspondingly a linker-error.
I don't know if this is the solution for the others, but by explicitly
defining BOOST_ALL_DYN_LINK (or BOOST_PROGRAM_OPTIONS_DYN_LINK) I can
now link my apps to a boost_program_options dll.
Regards,
André
On Wed, Oct 14, 2009 at 2:44 PM, Vladimir Prus
André Prins wrote:
Hi all,
I am having exactly the same problems when trying to link my main-app to a DLL-version of Boost::program_options. (using MSVC 9 and Boost 1.40).
main.obj : error LNK2001: unresolved external symbol "public: static unsigned int const boost::program_options::options_description::m_default_line_length" (?m_default_line_length@options_description@program_options@boost@@2IB)
For the first unresolved external, to the options_description::m_default_line_length, there is a workaround, by explicitly specifying a line-length as the second argument when constructing your descriptions. E.g.
po::options_description descriptions( "All options", 80 ); // Note the extra argument 80
main.obj : error LNK2001: unresolved external symbol "class std::basic_string
boost::program_options::arg" (?arg@program_options@boost@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) For the second unresolved external, I could not find a solution and I decided to build a static version of Boost::program_options. This solved both of these two problems.
It would be nice if somebody figure what this problem is and explain this to me. Or provide a patch ;-)
- Volodya
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users