【发布时间】:2012-06-18 11:26:42
【问题描述】:
由于 Boost 1.49 的问题,我无法通过 C++ 程序中的链接阶段。我已切换到 C++ (-std=c++11 -libc=libc++),它适用于另一段代码(也使用 boost)。 Boost 是使用自制软件安装的:
brew install boost --universal --with-mpi --with-icu
麻烦从boost::program_options开始。我收到这样的链接错误:
"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)
这有点奇怪,因为在使用的库上做一个 nm 显示,符号似乎在那里:
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 来哄自制软件使用 clang 而不是 gcc 来编译 boost。不确定我是否成功了。
非常感谢指针。
【问题讨论】:
标签: c++ boost c++11 osx-lion clang