如何build立与C ++ 0x支持的Boost?

我不知道如何用C ++ 0x编译器来构buildBoost。 必须给bjam哪个选项? 应该修改user.config文件吗?有人可以帮助我吗?

最好的,维森特

我find了答案。 我正在等待像“std”这样的function,并按照如下方式调用它:

 bjam std=0x 

但目前我们需要使用低级variablescxxflags并添加特定的编译器标志。 例如gcc我们可以做

 bjam toolset=gcc cxxflags=-std=gnu++0x 

其他编译器将需要不同的设置。

等待一个新的Boost.Buildfunction,你也可以定义你自己的工具集,如下所示:添加user.config或site.config文件

 using gcc : std0x : "/usr/bin/g++" # your path to the C++0x compiler : <cxxflags>-std=gnu++0x ; 

现在叫作

 bjam toolset=gcc-std0x 

要使用clang进行编译,请使用cxxflagslinkflags

 ./b2 \ ... cxxflags="-std=c++0x -stdlib=libc++" \ linkflags="-stdlib=libc++" \ ... 

debugging时,将-v传递给cxxflags也很有帮助。

使用这样的东西:

 ./bootstrap.sh --with-toolset=gcc --prefix=/usr/local ./b2 -j12 toolset=gcc variant=release link=shared threading=multi address-model=64 cxxflags=-std=c++11 install 

-j12用于并行(12个线程)build -std=c++11用于更好的兼容性, -std=gnu++11用于gnu扩展(仅适用于gcc)

如果boost :: mpi不是build(参见上面命令的输出) – >编辑user-config.jam

如果您只想构build特定组件,请执行以下操作:add:

 --with-libraries=system,thread,serialization 

例如

这里是我的框架从travis(调整ROOT_PATH )改编脚本:

 BOOST_DOWNLOAD_URL="http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download" BOOST_BUILD=${ROOT_PATH}/boostBuild mkdir -p ${BOOST_BUILD} wget --no-verbose --output-document="${ROOT_PATH}/boost.tar.bz2" "$BOOST_DOWNLOAD_URL" cd ${BOOST_BUILD} tar jxf "${ROOT_PATH}/boost.tar.bz2" --strip-components=1 -C "${BOOST_BUILD}" ./bootstrap.sh --with-toolset=gcc --with-libraries=system,thread,serialization,filesystem,chrono,atomic,date_time sudo ./b2 -j12 toolset=gcc threading=multi link=shared release install 

安装到/usr/local

我遇到了使用叮当编译Boost的文章: http : //blog.llvm.org/2010/05/clang-builds-boost.html 。 有可能使用Boost.Jam编译Boost编译器提供的更改,以适应您最喜爱的C ++ 0x编译器。

另外,你可以像这样改变一个文件的编译标志 :

exe test : test.cpp : <cxxflags>-std=gnu++0x ;

    Interesting Posts