Boost logo

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

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"
    boost::options_description::m_default_line_length and

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
now link my apps to a boost_program_options dll.


On Wed, Oct 14, 2009 at 2:44 PM, Vladimir Prus
<vladimir_at_[hidden]> wrote:
> 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_at_options_description_at_program_options_at_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<char,struct std::char_traits<char>,class
>>> std::allocator<char> > boost::program_options::arg"
>>> (?arg_at_program_options_at_boost@@3V?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_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_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at