如何设置 GNU G++ Visual Studio 2008 中的编译器
如何将 Visual studio 2008 编译器设置为 GNU GCC。我还可以将其具体到项目吗?我没有找到任何结论性的答案。
谢谢。
How do I set my Visual studio 2008 compiler to GNU GCC. Can I also make it specific to projects? I didn't find any conclusive answer.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
据我所知,没有办法做到这一点。 cl 或多或少与 Visual Studio 集成。
我想如果您真的很绝望,您可以尝试创建一个调用 gcc 的预构建步骤,然后执行某些操作来阻止 Visual Studio 构建发生。
As far as I know, there's no way to accomplish this. cl is more or less integrated with Visual Studio.
I guess if you were really desperate, you could try creating a pre-build step that invokes gcc and then doing something to stop the Visual Studio build from occurring.
使用外部构建系统。 (生成文件项目)。
Use external build system. (Makefile project).
您也许可以创建一个自定义 makefile 项目来为您解决这个问题。
Visual Studio的主流场景是成为MS开发工具的IDE。 Windows下使用GNU工具编译比较常见的方式是MinGW或Cygwin。
You may be able to make a custom makefile project to solve this for you.
Visual Studio's mainstream scenario is to be an IDE for MS developer tools. The more common ways to compile using GNU tools under Windows is MinGW or Cygwin.
为了获得最佳结果,请使用 GNU make、Visual Studio makefile 项目和您自己编写的工具。您的 makefile 是一个框架,用于编译文件(使用文件列表的变量),并且您的工具解析 .sln 和 .vcproj 文件以生成此文件列表。 makefile 包含结果。只需要一点胶水和苦劳——你会花一天的时间咒骂制造商不愿意做你想做的事,然后你就能让它工作了。一旦启动并运行,这种方法不需要太多维护。
您可以保持工具和 makefile 简单,只需将所有项目中的所有文件放入混合中并链接结果,使用文件模式来决定每个文件会发生什么,并将所有编译器选项放入 makefile 中。或者您可以变得更聪明,从项目中提取 #defines 并包含路径,并且可能添加一个 Win32 项目配置,makefile 生成器使用该配置来正确处理自定义构建步骤、排除的文件、编译器选项等。
简单的方法应该可以满足大多数人的需求,因为它允许任何人像平常一样向项目添加新文件,而不必关心 makefile,同时使人们很难意外地更改不想更改的设置。
我之前已经描述过这种方法(更详细一些):
在 VisualStudio 中使用 Makefile 的好技巧?
(一旦设置好它,它就可以很好地工作,并且在许多方面它实际上比通常的 VS 方法更方便,甚至在考虑到您现在可以使用的事实之前也是如此)其他编译器。)
For best results, use GNU make, a Visual Studio makefile project, and a tool that you write yourself. Your makefile is a skeleton, that compiles files (use a variable for the files list), and your tool parses the .sln and .vcproj files to generate this file list. The makefile includes the result. Just needs a bit of glue and elbow grease -- you'll spend a day cursing make's unwillingness to do what you want, then you'll get it working. Once up and running this approach doesn't require too much maintenance.
You can keep your tool and makefile simple, just throwing all files in all projects into the mix and linking the result, using file patterns to decide what happens to each file, and putting all compiler options in the makefile. Or you can get more clever, pull #defines and include paths from the project, and maybe add in a Win32 project configuration that the makefile generator uses to properly handle custom build steps, excluded files, compiler options, and so on.
The easy approach should satisfy most, because it lets anybody add new files to the project just as they normally do, without having to concern themselves with the makefile, whilst making it hard for people to accidentally change settings that don't want changing.
I have previously described this approach (with a tiny bit more detail):
Good techniques to use Makefiles in VisualStudio?
(Once you have it set up, it works well, and in many respects it's actually more convenient than the usual VS approach, even before taking into account the fact you can now use other compilers.)
您不能直接使用编译器。
但是,您可以调用 makefile,而不是使用内置构建系统。
配置示例:
mingw32-make
mingw32-make
创建makefile称为MinGWMakefile
,有 3 个目标:clean
、build
和rebuild
。如果您以前从未这样做过,这可能会非常乏味。在编译器消息上启用“转到行”功能:
您需要转换 gcc 的输出,从这样:
到这样:
我使用自定义 C++ 程序来执行此操作,但任何正则表达式工具都可以做到这一点。
You can't use the compiler directly.
You can, however, invoke a makefile instead of using the built-in build system.
Example of configuration:
mingw32-make
mingw32-make
calledMinGWMakefile
, with 3 targets:clean
,build
, andrebuild
. This can be very tedious if you've never done that before.Enable "go to line" functionality on compiler messages:
You need to transform the output of gcc, from this:
To this:
I was using a custom C++ program to do that, but any regular expression tool will do the trick.