gpt4 book ai didi

c++ - 如何从我的 jamfile 中将 cxxflags 传递给 Boost 库?

转载 作者:太空宇宙 更新时间:2023-11-04 11:46:41 24 4
gpt4 key购买 nike

我有一个项目有一些要求,其中之一是设置 c++11 编译器/链接器标志:

jamroot.jam:

project
: requirements
<toolset>clang:<cxxflags>"-stdlib=libc++ -std=c++11"
<toolset>clang:<linkflags>"-lc++"
# ... etc
;

lib mylibrary
: #sources
[ glob source/*.cpp ]
/boost/filesystem
/boost/system
/boost/thread//boost_thread
;

特定于库的源代码正在使用必要的 c++11 标志进行编译,但是提到的 Boost 库没有。这会导致无穷无尽的二进制不兼容和链接器错误。

我不想在用户配置或命令行中明确指定 cxxflags。我想确保 jamroot/jamfiles 是正确构建项目所必需的。

如何将所需的 cxxflags“传递”到依赖的 Boost 库?

更新:我最近尝试使用别名 来实现我的目标。来自 the docs :

Another use of the alias rule is to change build properties. For example, if you want to use link statically to the Boost Threads library, you can write the following:

alias threads : /boost/thread//boost_thread : <link>static ;

然而,为 boost_filesystem 设置并重建,比如说,path.cpp 仍然忽略了我试图构建的属性。

最佳答案

这已由 setting up a feature 解决(感谢 Steven Watanabe):

feature.feature cpp11 :
on :
composite optional propagated
;

feature.compose <cpp11>on :
<cxxflags>"-stdlib=libc++ -std=c++11"
<define>BOOST_NO_CXX11_NUMERIC_LIMITS=1
<linkflags>"-lc++"
;

project
: requirements
<cpp11>on
# ... etc
;

显然这是让变量传播到依赖库的唯一方法。

关于c++ - 如何从我的 jamfile 中将 cxxflags 传递给 Boost 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19599194/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com