windows下使用scons编译C++代码,scons添加“/Fo"作为编译选项 [英] Using scons to compile C++ code under windows, scons adds "/Fo" as compile option

查看:170
本文介绍了windows下使用scons编译C++代码,scons添加“/Fo"作为编译选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Using the following: Python version 2.7.13, Scons version 2.5.1, Visual Studio 2012 express is installed, but I am not planning to use it. Code blocks and MinGW-W64-builds-4.3 are installed.

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

Using Scons to compile C++ code (networkit toolkit) under windows. Scons adds "/Fo" as compile option. This option works only with VC++ and not with MinGW which I am trying to use. Why does Scons add this flag? I have checked my Sconstruct and the reference build.conf files and cannot seem to find this flag getting set explicitly.

我的 Sconstruct 文件在这里(http://www103.zippyshare.com/v/jSrMapGz/file.html)和 build.conf 文件在这里(http://www11.zippyshare.com/v/aXGQA5b5/file.html).

My Sconstruct file is here(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 是从哪里挑选这个标志的 :(

I want to get the compilation done with "-o" flag for g++, which is the equivalent of /Fo flag for VC++. I just cant figure out where Scons is picking this flag from :(

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

I am a novice with python and scons. I typically use VC++ 2012 but have to use networkit toolkit for a project, but it uses C11 features. And I cannot update to VC++ 2015/2017 yet.

感谢您的帮助!

推荐答案

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

I checked your SConstruct file, and you are initialising your build environment as

env = Environment()

,这将环境变量tools"设置为其标准值default".后一个设置的意思是:让 SCons 找出当前系统中安装了哪些工具/编译器,并自动将相应的 Builders 添加到构建环境中.在 Windows 下,SCons 会更喜欢vc"而不是mingw"……目前这是硬编码的(我们正在努力为未来版本的核心源代码改变这一点).

, which leaves the environment variable "tools" set to its standard value "default". The latter setting means: let SCons figure out which tools/compilers are installed in the current system, and add corresponding Builders to the build environment automatically. Under Windows, SCons will prefer "vc" over "mingw"...this is hardcoded at the moment (we're working on changing this for future versions of the core source).

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

What you can do, since you know that you have a "mingw" compiler installed that you want to use explicitly, is to tell SCons that you want to work with "mingw" only. The following example from the page https://bitbucket.org/scons/scons/wiki/SconstructShortMingwWin32 shows the basic recipe for this:

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'))

如需进一步帮助和参考,请考虑查看我们的用户指南手册页.

For further help and as reference, please consider checking out our User Guide and Man page.

这篇关于windows下使用scons编译C++代码,scons添加“/Fo"作为编译选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆