如何设置 GNU G++ Visual Studio 2008 中的编译器

发布于 2024-09-12 12:29:18 字数 84 浏览 11 评论 0原文

如何将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

偏爱你一生 2024-09-19 12:29:25

据我所知,没有办法做到这一点。 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.

纵山崖 2024-09-19 12:29:24

使用外部构建系统。 (生成文件项目)。

Use external build system. (Makefile project).

反差帅 2024-09-19 12:29:23

您也许可以创建一个自定义 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.

若水微香 2024-09-19 12:29:22

为了获得最佳结果,请使用 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.)

以可爱出名 2024-09-19 12:29:21

您不能直接使用编译器。

但是,您可以调用 makefile,而不是使用内置构建系统。

配置示例:

  1. 安装MinGW(我猜这一步已经完成了),包括mingw32-make
  2. mingw32-make创建makefile称为 MinGWMakefile ,有 3 个目标:cleanbuildrebuild。如果您以前从未这样做过,这可能会非常乏味。
  3. 为您的项目创建新配置
  4. 转到配置属性->常规->配置类型,然后选择“makefile”
  5. 转到配置属性->NMake,然后使用以下命令行:
    构建命令行:mingw32-make -f MinGWMakefile build
    重建命令行:mingw32-make -f MinGWMakefile重建
    清理命令行:mingw32-make -f MinGWMakefile clean

在编译器消息上启用“转到行”功能:

您需要转换 gcc 的输出,从这样:

filename:line:message

到这样:

filename(line):message

我使用自定义 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:

  1. Install MinGW (I guess this step is already done), including mingw32-make
  2. Create a makefile for mingw32-make called MinGWMakefile , with 3 targets: clean, build, and rebuild. This can be very tedious if you've never done that before.
  3. Create a new configuration for your project
  4. Go to configuration properties->general->configuration type, and select "makefile"
  5. Go to configuration properties->NMake, and use these command lines:
    Build Command Line: mingw32-make -f MinGWMakefile build
    ReBuild Command Line: mingw32-make -f MinGWMakefile rebuild
    Clean Command Line: mingw32-make -f MinGWMakefile clean

Enable "go to line" functionality on compiler messages:

You need to transform the output of gcc, from this:

filename:line:message

To this:

filename(line):message

I was using a custom C++ program to do that, but any regular expression tool will do the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文