如何安装Boost与指定的编译器(说GCC) [英] How to install Boost with specified compiler (say GCC)
问题描述
我想使用指定的编译器(例如 gcc-4.9.1
)安装 boost
安装在< gcc_49_root>
中。当前的操作系统是Mac OS X 10.9.4,但我想这个安装过程在其他操作系统上工作。 boost
的文档对于这种情况是相当不透明的。我试过的如下:
I would like to install boost
with specified compilers, such as the gcc-4.9.1
that I have installed in <gcc_49_root>
. The current OS is Mac OS X 10.9.4, but I would like this installation process to work on other OS. The documentation of boost
is quite opaque about this scenario. What I have tried is as following:
$ ./bootstrap.sh
-n Building Boost.Build engine with toolset darwin...
tools/build/src/engine/bin.macosxx86_64/b2
-n Detecting Python version...
2.7
-n Detecting Python root...
/System/Library/Frameworks/Python.framework/Versions/2.7
-n Unicode/ICU support for Boost.Regex?...
not found.
Generating Boost.Build configuration in project-config.jam...
插入使用gcc:4.9.1:< gcc_49_root> / bin / g ++ - 4.9:; into
project-config.jam
。
$ ./b2 --prefix=<...> toolset=gcc-4.9.1 install
但遇到错误:
Jamfile</Users/dongli/Shares/works/packman/test/packages/Boost/boost_1_56_0/libs/context/build>.gas64 bin.v2/libs/context/build/gcc-4.9.1/release/address-model-64/architecture-x86/threading-multi/asm/make_x86_64_sysv_macho_gas.o
FATAL:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/as/x86_64/as: I don't understand '-' flag!
clang: error: no input files
cpp -x assembler-with-cpp "libs/context/src/asm/make_x86_64_sysv_macho_gas.S" | as --64 -o "bin.v2/libs/context/build/gcc-4.9.1/release/address-model-64/architecture-x86/threading-multi/asm/make_x86_64_sysv_macho_gas.o"
...failed Jamfile</Users/dongli/Shares/works/packman/test/packages/Boost/boost_1_56_0/libs/context/build>.gas64 bin.v2/libs/context/build/gcc-4.9.1/release/address-model-64/architecture-x86/threading-multi/asm/make_x86_64_sysv_macho_gas.o...
gcc.link.dll bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/libboost_atomic.dylib
ld: unknown option: -h
collect2: error: ld returned 1 exit status
"/usr/local/opt/gcc/bin/g++-4.9" -o "bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/libboost_atomic.dylib" -Wl,-h -Wl,libboost_atomic.dylib -shared -Wl,--start-group "bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/lockpool.o" -Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group
...failed gcc.link.dll bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/libboost_atomic.dylib...
我应该如何处理这些错误?提前感谢!
What should I do with these errors? Thanks in advance!
推荐答案
Apple的链接器ld(ld64)与其他UNIX / GNU链接器不同,例如-h(soname),--start-group, - end-group等。你得到的那些错误(未知选项)是尝试传递不支持的标志到Apple的ld当你指定gcc工具集的结果。
Apple's linker ld(ld64) is different from other UNIX/GNU linkers and does not support some options, such as -h(soname), --start-group, --end-group, etc,. Those errors you got("unknown option") were the results of trying to pass non-supported flags to Apple's ld when you specify the gcc toolset.
我攻击我的方式是首先在项目配置文件中包含darwin:
The way I hacked mine was to first include "darwin" in the project config file:
using gcc : 4.9.1 : <gcc_49_root>/bin/g++-4.9 : <linker-type>darwin ;
接下来从{BOOST_DIR} / tools / build / src / tools / gcc中删除不支持的标志.jam,从action link.dll bind LIBRARIES块中的long命令:
Next removing the non-supported flags from {BOOST_DIR}/tools/build/src/tools/gcc.jam, from the long command in the "actions link.dll bind LIBRARIES" block:
remove/comment out this portion:
... $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) ...
然后Boost库编译没有错误,并在其他gcc4.9编译代码工作正常。
Afterwards the Boost libraries built without errors and worked fine in other gcc4.9 compiled codes.
$ ./bootstrap.sh --with-toolset=gcc
$ ./b2 --toolset=gcc-4.9.1
UPDATE我最近在Yosemite(10.10.1)上新建了一个gcc 5.1.0和Boost 1.58.0。相同的修复对我有用。
UPDATE (May 2015): I recently did a new built of gcc 5.1.0 and Boost 1.58.0 on Yosemite (10.10.1). Same fix worked for me.
这篇关于如何安装Boost与指定的编译器(说GCC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!