与链接的boost :: program_options烦恼OSX上使用LLVM [英] Linking troubles with boost::program_options on OSX using LLVM
问题描述
我无法通过我的C ++程序的链接阶段获得由于与升压1.49的问题。我已经切换到C ++(-std = C ++ 11 -libc =的libc ++)这对于另一块code的正常工作(也使用升压)。使用带有自制安装升压:
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
麻烦始于的boost :: program_options。我得到的链接错误是这样的:
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
我已经尝试自制哄通过设置CXX和CXX_FLAGS因此在安装前编译铿锵而不是gcc提升。不知道我成功了,但。
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.
指针大大AP preciated。
Pointers greatly appreciated.
推荐答案
您将需要重新编译铿锵和STD11标志提振,libc中++库之前不是二进制与OSX(GCC很早的版本已安装的libstdc ++兼容更改为GPL3)。如果您铿锵的版本是3.1或以上,那么你可以使用(否则改变C ++ 11的C ++ 0x的早期版本)。
You will need to recompile boost with clang and std11 flags, the libc++ library is not binary compatible with the installed libstdc++ in OSX (very early version of gcc prior to changing to gpl3). If your version of clang is 3.1 or over then you can use (otherwise change c++11 to c++0x for earlier versions).
./bootstrap.sh
mkdir build
sudo ./bjam toolset=clang cxxflags="-std=c++0x -stdlib=libc++" variant=release link=static threading=multi runtime-link=shared --build-dir=Build --layout=system --without-mpi --without-python install --prefix=/usr/local
您当然可以改变任何这些如你所愿,除了
You can of course alter any of these as you wish except
工具=铛CXXFLAGS = - STD =的C ++ 0x -stdlib = libc的+ +
toolset=clang cxxflags="-std=c++0x -stdlib=libc++"
这应该为你工作。
这篇关于与链接的boost :: program_options烦恼OSX上使用LLVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!