Opened 11 years ago

Last modified 7 years ago

#6797 new Support Requests

Undefined references for program_options library with mingw64.

Reported by: tasptz@… Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc:

Description

I compiled a shared version of boost program_options with mingw64. When I try to link against it I get:

Linking CXX executable ..\..\..\binary\abc.exe
CMakeFiles\abc.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x65bf): undefined reference to `boost::program_options::detail::common_config_file_iterator::c
ommon_config_file_iterator(std::set<std::string, std::less<std::string>, std::allocator<std::string> > const&, bool)'
CMakeFiles\abc.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x6672): undefined reference to `boost::program_options::detail::common_config_file_iterator::g
et()'
CMakeFiles\abc.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x7871): undefined reference to `boost::program_options::detail::common_config_file_iterator::g
et()'
collect2: ld returned 1 exit status

I use cmake for my project and everything works fine under linux. nm gives the following output:

$ nm libboost_program_options.dll | grep common_config_file_iterator
000000006e1a62c0 d .data$_ZTIN5boost12eof_iteratorINS_15program_options6detail27common_config_file_iteratorENS1_12basic_optionIcEEEE
000000006e1a62e0 d .data$_ZTIN5boost15iterator_facadeINS_15program_options6detail27common_config_file_iteratorEKNS1_12basic_optionIcEENS_21forward_traversal_tag
ERS6_xEE
000000006e1a6660 d .data$_ZTIN5boost15program_options6detail27common_config_file_iteratorE
000000006e1a96a0 d .data$_ZTVN5boost15program_options6detail27common_config_file_iteratorE
000000006e1b578c p .pdata$_ZN5boost15program_options6detail27common_config_file_iterator7getlineERSs
000000006e1b58d0 p .pdata$_ZN5boost15program_options6detail27common_config_file_iteratorD0Ev
000000006e1b58c4 p .pdata$_ZN5boost15program_options6detail27common_config_file_iteratorD1Ev
000000006e1b5d38 p .pdata$_ZN5boost15program_options6detail27common_config_file_iteratorD2Ev
000000006e1b18e0 r .rdata$_ZTSN5boost12eof_iteratorINS_15program_options6detail27common_config_file_iteratorENS1_12basic_optionIcEEEE
000000006e1b1960 r .rdata$_ZTSN5boost15iterator_facadeINS_15program_options6detail27common_config_file_iteratorEKNS1_12basic_optionIcEENS_21forward_traversal_ta
gERS6_xEE
000000006e1b20e0 r .rdata$_ZTSN5boost15program_options6detail27common_config_file_iteratorE
000000006e108c20 t .text$_ZN5boost15program_options6detail27common_config_file_iterator7getlineERSs
000000006e108c30 t .text$_ZN5boost15program_options6detail27common_config_file_iteratorD0Ev
000000006e108e00 t .text$_ZN5boost15program_options6detail27common_config_file_iteratorD1Ev
000000006e108fc0 t .text$_ZN5boost15program_options6detail27common_config_file_iteratorD2Ev
000000006e1be600 r .xdata$_ZN5boost15program_options6detail27common_config_file_iterator7getlineERSs
000000006e1be74c r .xdata$_ZN5boost15program_options6detail27common_config_file_iteratorD0Ev
000000006e1be740 r .xdata$_ZN5boost15program_options6detail27common_config_file_iteratorD1Ev
000000006e1beadc r .xdata$_ZN5boost15program_options6detail27common_config_file_iteratorD2Ev
000000006e198fe0 t _GLOBAL__sub_I__ZN5boost15program_options6detail27common_config_file_iteratorC2ERKSt3setISsSt4lessISsESaISsEEb
000000006e0cd800 T _ZN5boost15program_options6detail27common_config_file_iterator10add_optionEPKc
000000006e0cde20 T _ZN5boost15program_options6detail27common_config_file_iterator3getEv
                 U _ZN5boost15program_options6detail27common_config_file_iterator7getlineERSs
000000006e108c20 T _ZN5boost15program_options6detail27common_config_file_iterator7getlineERSs
000000006e0ceda0 T _ZN5boost15program_options6detail27common_config_file_iteratorC1ERKSt3setISsSt4lessISsESaISsEEb
000000006e0da700 t _ZN5boost15program_options6detail27common_config_file_iteratorC2ERKS2_.constprop.235
000000006e0ceda0 T _ZN5boost15program_options6detail27common_config_file_iteratorC2ERKSt3setISsSt4lessISsESaISsEEb
000000006e108c30 T _ZN5boost15program_options6detail27common_config_file_iteratorD0Ev
                 U _ZN5boost15program_options6detail27common_config_file_iteratorD0Ev
                 U _ZN5boost15program_options6detail27common_config_file_iteratorD1Ev
000000006e108e00 T _ZN5boost15program_options6detail27common_config_file_iteratorD1Ev
000000006e108fc0 T _ZN5boost15program_options6detail27common_config_file_iteratorD2Ev
000000006e0cd660 T _ZNK5boost15program_options6detail27common_config_file_iterator14allowed_optionERKSs
000000006e1a62c0 D _ZTIN5boost12eof_iteratorINS_15program_options6detail27common_config_file_iteratorENS1_12basic_optionIcEEEE
000000006e1a62e0 D _ZTIN5boost15iterator_facadeINS_15program_options6detail27common_config_file_iteratorEKNS1_12basic_optionIcEENS_21forward_traversal_tagERS6_x
EE
000000006e1a6660 D _ZTIN5boost15program_options6detail27common_config_file_iteratorE
000000006e1b18e0 R _ZTSN5boost12eof_iteratorINS_15program_options6detail27common_config_file_iteratorENS1_12basic_optionIcEEEE
000000006e1b1960 R _ZTSN5boost15iterator_facadeINS_15program_options6detail27common_config_file_iteratorEKNS1_12basic_optionIcEENS_21forward_traversal_tagERS6_x
EE
000000006e1b20e0 R _ZTSN5boost15program_options6detail27common_config_file_iteratorE
000000006e1a96a0 D _ZTVN5boost15program_options6detail27common_config_file_iteratorE

The command I use to build boost is:

b2 --toolset=gcc variant=release address-model=64 threading=multi optimization=speed link=shared runtime-link=shared cxxflags='-DBOOST_USE_WINDOWS_H -std=gnu++0x -march=core2 -mtune=core2 -msse -msse2 -mssse3 -msse4' --with-thread --with-dat
e_time --with-filesystem --with-program_options --prefix=c:/temp/boost install

I attach a minimal cmake project (I used Boost 1.48.0 there, but it makes no difference).

Attachments (1)

po.zip (218.1 KB ) - added by tasptz@… 11 years ago.

Download all attachments as: .zip

Change History (7)

by tasptz@…, 11 years ago

Attachment: po.zip added

comment:1 by anonymous, 11 years ago

In the attached project the boost headers are missing (file size limitation).

comment:2 by anonymous, 9 years ago

as your comment, the built libs on linux is working, but fails to work on windows, i think this is because of the common_config_file_iterator' export.

i add this fix, and it works on windows with .dll suffix:

class BOOST_PROGRAM_OPTIONS_DECL common_config_file_iterator

: public eof_iterator<common_config_file_iterator, option>

{

comment:4 by dani@…, 9 years ago

https://github.com/boostorg/program_options/pull/1 fixes compilation failures on (at least) vc10, vc11, and vc12 introduced with commit 4ae33ce.

comment:5 by mlt, 7 years ago

I'm surprised it didn't make it into 1.58.

Note: See TracTickets for help on using tickets.