Re: [Boost-users] dynamic link error: boost::program_options::arg not found (Sebastian Hauer)
Hi Sebastian and Ovanes,
I am facing the same problems as you with linking to boost::program_options, and boost::system too.
In all my win32 projects (I use msvc9.0), I define BOOST_DYN_LIB using a common property sheet.
It compiles just fine with 1.36.0 but it does not link.
I also specify BOOST_LIB_DIAGNOSTIC so that I can see what boost auto link is trying to do.
May be I should say that I built my boost 1.36.0 libraries on Win32 (Windows XP Professional SP3) using following command line:
./bjam.exe toolset=msvc --build-type=complete --build-dir="D:\tmp" --threading=multi --runtime-link=static,shared --prefix="C:\boost1.36"
install --without-mpi --without-python --without-wave
When I compile my project (some libraries using boost_filesystem and boost_system, some not), I can see in the compiler output:
Linking to lib file: boost_filesystem-vc90-mt-1_36.lib
Linking to lib file: boost_system-vc90-mt-1_36.lib
When I compile my main :
#include <iostream>
#include
C:\Programme\MicrosoftVisualStudio9.0\VC\include\stdexcept(21) : see declaration of 'std::logic_error' ../../../../boost/include/boost-1_36\boost/program_options/errors.hpp(21) : see declaration of 'boost::program_options::error' ../../../../boost/include/boost-1_36\boost/program_options/errors.hpp(61) : warning C4251:
'boost::program_options::ambiguous_option::alternatives' : class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::ambiguous_option'
with [ _Ty=std::string ]
[snip a lot of similar warnings]
Then, linking with following command line
/OUT:"../../Release\MyApp.exe" /INCREMENTAL /NOLOGO /LIBPATH:"../../Release" /LIBPATH:"..\..\..\..\boost/lib/vc90" /MANIFEST
/MANIFESTFILE:"../../Release/MyApp\MyApp.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/NODEFAULTLIB:"libcpmt.lib" /NODEFAULTLIB:"libcmt.lib" /SUBSYSTEM:CONSOLE /DYNAMICBASE:NO /MACHINE:X86 /ERRORREPORT:PROMPT msvcrt.lib
msvcprt.LIB binmode.obj kernel32.lib user32.lib netapi32.lib Iphlpapi.lib Ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
I get following errors:
Memain.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall
boost::program_options::detail::cmdline::set_additional_parser(class boost::function1
,class std::basic_string
const &>)"
(__imp_?set_additional_parser@cmdline@detail@program_options@boost@@QAEXV?$function1@U?$pair@V?$basic_string@DU?$char_traits@D@std@@V?$alloc
ator@D@2@@std@@V12@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@4@@Z) referenced in function "public: class
boost::program_options::basic_command_line_parser<char> & __thiscall
boost::program_options::basic_command_line_parser<char>::extra_parser(class boost::function1 const &>)" (?extra_parser@?$basic_command_line_parser@D@program_options@boost@@QAEAAV123@V?$function1@U?$pair@V?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@V12@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@3@@Z)
1>metiscalibrationdata.lib(MetisMatrixCalibration_io.obj) : error LNK2019: unresolved external symbol "class boost::system::error_category
const & __cdecl boost::system::get_generic_category(void)" (?get_generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in
function "void __cdecl boost::system::`dynamic initializer for 'generic_category''(void)" (??__Egeneric_category@system@boost@@YAXXZ)
error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl
boost::system::get_generic_category(void)" (__imp_?get_generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function
"void __cdecl boost::system::`dynamic initializer for 'generic_category''(void)" (??__Egeneric_category@system@boost@@YAXXZ)
1>filesystem.lib(FileUtils.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const
& __cdecl boost::system::get_generic_category(void)" (__imp_?get_generic_category@system@boost@@YAABVerror_category@12@XZ)
1>filesystem.lib(FileUtils.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_code
boost::filesystem::detail::throws" (__imp_?throws@detail@filesystem@boost@@3Verror_code@system@3@A) referenced in function "void __cdecl
boost::filesystem::remove
Hello Florent, To check if a symbol is exported correctly I simply use dumpbin which is a command line tool that comes with msvc. E.g.: dumpbin /exports ..\boost_1_36_0\lib.x86-nt-msvc8\boost_program_options-vc80-mt-gd-1_36.lib | grep program_options::arg The "non dll-interface" warnings are OK, but am I missing something or are you not linking against boost_program_options-*.lib ? I have to say that I currently don't use auto linking maybe you should try adding all libraries manually and turn off the auto linking feature by defining: BOOST_ALL_NO_LIB=1. Regards, Sebastian
participants (2)
-
Sebastian Hauer
-
Vial, Florent