Ion*_*chy 8 c++ boost clang osx-lion c++11
由于Boost 1.49的问题,我无法在C++程序中完成链接阶段.我已经切换到C++(-std=c++11 -libc=libc++
),它适用于另一段代码(也使用boost).使用自制软件安装Boost:
brew install boost --universal --with-mpi --with-icu
Run Code Online (Sandbox Code Playgroud)
问题始于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)
Run Code Online (Sandbox Code Playgroud)
这有点奇怪,因为在使用的库上做一个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
Run Code Online (Sandbox Code Playgroud)
我已经尝试通过在安装之前相应地设置CXX和CXX_FLAGS来哄骗homebrew来编译boost而不是gcc.不确定我成功了.
指针非常感谢.
您需要使用clang和std11标志重新编译boost,libc ++库与OSX中安装的libstdc ++不兼容(在更改为gpl3之前的gcc的早期版本).如果您的clang版本是3.1或更高,那么您可以使用(否则将c ++ 11更改为早期版本的c ++ 0x).
./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
Run Code Online (Sandbox Code Playgroud)
您可以根据需要更改其中任何一项,除非
toolset = clang cxxflags =" - std = c ++ 0x -stdlib = libc ++"
这应该适合你.
归档时间: |
|
查看次数: |
6640 次 |
最近记录: |