如何在Boost.Build 2018.02-git中传递-fvisibility=hidden编译旗标?
问题描述
尝试通过命令b2 (...) linkflags=-fvisibility=hidden (...)向Boost.Build 2018.02-git传递GCC的-fvisibility=hidden可见性选项时,触发如下错误:
/usr/share/boost-build/src/build/property.jam:358: in validate1 from module property error: Invalid property '<visibility>hidden': unknown feature 'visibility'. /usr/share/boost-build/src/build/property.jam:367: in property.validate from module property /usr/share/boost-build/src/build/property-set.jam:493: in property-set.create-with-validation from module property-set
解决方案
你的Boost.Build版本过旧,未内置visibility特性支持,需通过以下方式直接传递原始选项:
方法1:通过
cxxflags传递编译选项-fvisibility=hidden本质是编译阶段控制符号可见性的参数,直接用cxxflags传递即可:b2 cxxflags=-fvisibility=hidden [其他参数]方法2:通过
<linkflags>传递链接选项
如果需要在链接阶段也传递该选项,使用<linkflags>的完整语法,避免被Boost.Build解析为内部特性:b2 <linkflags>-fvisibility=hidden [其他参数]方法3:在Jamfile中全局配置
若通过Jamfile管理构建,可添加以下规则全局设置编译和链接选项:toolset.flags gcc.compile OPTIONS : -fvisibility=hidden ; toolset.flags gcc.link OPTIONS : -fvisibility=hidden ;
内容的提问来源于stack exchange,提问作者Gabriel Devillers
相关产品推荐
相关产品推荐

