windows下使用scons编译C++代码,scons添加"/Fo"作为编译选项

Using scons to compile C++ code under windows, scons adds "/Fo" as compile option

使用以下内容: Python version 2.7.13, Scons version 2.5.1, Visual Studio 2012 express 安装了,但是我不打算用。 已安装代码块和 MinGW-W64-builds-4.3。

在windows下使用Scons编译C++代码(networkit工具包)。 Scons 添加“/Fo”作为编译选项。此选项仅适用于 VC++ 而不适用于我尝试使用的 MinGW。为什么 Scons 要添加这个标志?我已经检查了我的 Sconstruct 和参考 build.conf 文件,但似乎无法找到明确设置的标志。

我的构造文件在这里(http://www103.zippyshare.com/v/jSrMapGz/file.html) and the build.conf file is here (http://www11.zippyshare.com/v/aXGQA5b5/file.html)。

我想用 g++ 的“-o”标志完成编译,这相当于 VC++ 的 /Fo 标志。我只是不知道 Scons 从哪里挑选这个标志:(

我是python和scons的新手。我通常使用 VC++ 2012,但必须为项目使用 networkit 工具包,但它使用 C11 功能。我还不能更新到 VC++ 2015/2017。

感谢您的帮助!

我检查了你的 SConstruct 文件,你正在将构建环境初始化为

env = Environment()

,将环境变量 "tools" 设置为其标准值 "default"。后面的设置意思是:让SCons判断当前系统安装了哪些tools/compilers,并自动将相应的Builder添加到构建环境中。在 Windows 下,SCons 将更喜欢 "vc" 而不是 "mingw"...目前这是硬编码的(我们正在努力为核心源的未来版本更改它)。

你可以做什么,因为你知道你安装了一个你想明确使用的 "mingw" 编译器,告诉 SCons 你只想使用 "mingw"。 页面 https://bitbucket.org/scons/scons/wiki/SconstructShortMingwWin32 中的以下示例显示了此的基本方法:

import os

#don't use the default environment
DefaultEnvironment(tools=[])
#create an environment that uses mingw tools
env = Environment(ENV=os.environ, tools=['mingw'])

#the target will be myprogram.exe (in win32)
#the source files will be every file in the 
#current directory that matches "*.cpp"
env.Program(target='myprogram', source = Glob('*.cpp'))

如需进一步帮助和参考,请考虑查看我们的User Guide and Man page