I'm having trouble getting through the linking phase in my C++ program due to problems with Boost 1.49. I have switched to C++ (-std=c++11 -libc=libc++
) which works fine for another piece of code (which also uses boost). Boost was installed using homebrew with:
brew install boost --universal --with-mpi --with-icu
The trouble starts with boost::program_options
. I get the link errors like this:
"boost::program_options::validate(boost::any&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, int)", referenced from:
... etc. ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is a little strange, because doing an nm on the library used reveals, that the symbol appears to be there:
nm -U /usr/local/lib/libboost_program_options-mt.dylib | grep validate
0000000000019880 - 01 0000 FUN __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISbIwSt11char_traitsIwESaIwEESaIS7_EEPSsi
0000000000019880 T __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISbIwSt11char_traitsIwESaIwEESaIS7_EEPSsi
00000000000199e0 - 01 0000 FUN __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISbIwSt11char_traitsIwESaIwEESaIS7_EEPbi
00000000000199e0 T __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISbIwSt11char_traitsIwESaIwEESaIS7_EEPbi
0000000000019930 T __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISsSaISsEEPSsi
0000000000019930 - 01 0000 FUN __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISsSaISsEEPSsi
0000000000019c70 - 01 0000 FUN __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISsSaISsEEPbi
0000000000019c70 T __ZN5boost15program_options8validateERNS_3anyERKSt6vectorISsSaISsEEPbi
I have already tried coaxing homebrew to compile boost with clang instead of gcc by setting CXX and CXX_FLAGS accordingly prior to installation. Not sure I succeeded though.
Pointers greatly appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…