在VS 2005(8)IDE中使用GCC [英] Using GCC from within VS 2005(8) IDE

查看:179
本文介绍了在VS 2005(8)IDE中使用GCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们的项目是跨平台的-platform,而且我经常从我的同事遇到麻烦,因为我正在检查不符合标准的代码(这是可以归因于VS编译器!)。

我仍然希望能够使用MS编译器编译,所以我可以继续调试等,但是我希望能够切换以使用GCC进行编译,这样我就可以确定我不会打破其他平台上的构建。



这可能吗?

解决方案

我要提出的建议仍然需要makefile,所以我部分地重复先前的答复。或者,如前所述,也许你已经有了一个makefile,在这种情况下,为了完成我要描述的内容,你将会有更少的步骤。



一旦知道了用于在代码上调用make或g ++的特定Windows命令行命令,就可以在Visual Studio项目中创建一个预生成事件。 (Project Properties >> Configuration Properties >> Build Events >> Pre-Build Event)。



预生成事件可以调用bat文件脚本或任何你的机器上的其他脚本,并且该脚本将能够返回错误代码。从本质上讲,脚本OK或脚本失败是脚本可以返回到Visual Studio的通信量范围。



脚本不会自动查看所有的Visual Studio环境变量(例如$(InputDir),$(ProjectDir),$(SolutionName)等),但是您可以在指定如何调用脚本时使用这些变量。换句话说,您可以将这些值作为参数传递给脚本。



设置此值,以便每次在Visual Studio中生成时,预生成事件都将FIRST尝试在你的代码上运行make / g ++。如果您的脚本(调用make / g ++的脚本)检测到任何问题,那么该脚本会返回一个错误,并且该构建可以立即停止。该脚本可以打印到stdout或stderr,并且在Visual Studio Build输出窗口(该窗口通常显示========== Build:3 succeeded,0 failed这样的窗口) )。



您可以打印脚本:

BUILD FAILED,检测到非可移植代码,使/ g ++返回以下内容:.........



这样,您不必记得定期从Visual Studio切换到命令线。它会在您每次构建时自动完成。


Is there a way to utilise the GCC compiler whilst still being able to develop via the Visual Studio IDE?

Our project is cross-platform, and I quite frequently get into trouble from my colleague because I'm checking in code that's not standards compliant (this can be attributed to the VS compiler!).

I'd still like to be able to compile using the MS compiler, so I can continue debugging, etc, however I'd like to be able to switch to compile using GCC, just so that I can be sure I'm not breaking the build on other platforms.

Is this possible?

解决方案

What I am about to suggest would still require a makefile, so I am partially repeating the advice from an earlier reply. Or, as was also mentioned earlier, maybe you already have a makefile, in which case you will have even fewer steps in order to accomplish what I am about to describe.

Once you know your specific windows command-line command for invoking make or g++ on your code, then you create a "Pre-Build Event" in your Visual Studio Project. ("Project Properties >> Configuration Properties >> Build Events >> Pre-Build Event").

The pre-build event can call a bat file script, or any other script on your machine, and that script will be able to return an error-code. Essentially, "script OK," or "script FAILED" is the extent of the amount of communication your script can have BACK to visual studio.

The script doesn't automatically see all the visual studio environment variables (such as $(InputDir), $(ProjectDir), $(SolutionName), etc), however you can use those variables when you specify how to call the script. In other words, you can pass those values to the script as arguments.

Set this up so that every time you build in Visual Studio, the pre-build event will FIRST try to run make/g++ on your code. If your script (the one that calls make/g++) detects any problems, then the script returns an error and the build can be STOPPED right then and there. The script can print to stdout or stderr and that output should be visible to you in the Visual Studio Build output window (the window that usually shows stuff like "========== Build: 3 succeeded, 0 failed").

You can have the script print:

"BUILD FAILED, non-portable code detected, make/g++ returned the following:........."

This way, you don't have to remember to periodically switch from Visual Studio to the command line. It will be automatically done for you every time you build.

这篇关于在VS 2005(8)IDE中使用GCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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