Boost Users :
Subject: Re: [Boost-users] msvc fail to link with dynamic boost_program_options library
From: André Prins (a.h.prins_at_[hidden])
Date: 2009-11-26 10:12:48
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"
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.
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
>>> main.obj : error LNK2001: unresolved external symbol "public: static
>>> unsigned int const
>> 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<char,struct std::char_traits<char>,class
>>> std::allocator<char> > boost::program_options::arg"
>> 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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net