【发布时间】:2014-11-24 11:40:34
【问题描述】:
我正在使用 scons 进行构建。我遇到了以下警告(在编译一些用于多个构建目标的类时):
scons: warning: Two different environments were specified for target /home/stackuser/src/dsl/build/debug/common/LocalLog.o,
but they appear to have the same action: $CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES
因此,解决此警告的公认方法是在通用 cpp 文件的源列表中使用 env.Object:
client_srcs = [
env.Object("../common/LocalLog.cpp"),
env.Object("../common/LogMsg.cpp"),
"LogWriter.cpp",
"QueueConsumer.cpp",
env.Object("../common/QueueStore.cpp"),
env.Object("../common/TimeFunctions.cpp")
]
但是,当围绕常见的 cpp 文件使用此 env.Object 函数时,某些目标无法构建(链接器错误链接到 boost):
/usr/include/boost/system/error_code.hpp:208: undefined reference to `boost::system::get_system_category()'
/usr/include/boost/system/error_code.hpp:209: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::get_generic_category()'
此链接器错误为described here;总结接受的答案:
当静态链接时,链接器期望库会出现 在包含对它们的引用的文件之后。你需要移动你的 -l 标志之前的 .o 文件。
但是,如果我只是删除 SConscript 中的 env.Object 调用,我会收到这些 scons 警告,但编译和链接是成功的。
我只想忽略这些 scons 警告; (如何)我可以关闭它们吗?
【问题讨论】:
标签: scons