C++ 我需要在 VS 上更改编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14958778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 18:50:56  来源:igfitidea点击:

I need to change compiler on VS

c++visual-studiogcccompiler-constructionsdl

提问by Giwrgos Tsopanoglou

I have made a sudoku solver using SDL (for GUI) on VCpp 2010 IDE.

我在 VCpp 2010 IDE 上使用 SDL(用于 GUI)制作了一个数独求解器。

The program compiles without errors and runs fine. However, i cannot pass the compiled executable on to some people because they don't have msvc dll on their pc.

该程序编译没有错误并且运行良好。但是,我无法将编译后的可执行文件传递给某些人,因为他们的 pc 上没有 msvc dll。

I thought i could use devc++ that compiles with GCC but this IDE is kinda buggy and just won't let me include some header files.I also have some problems setting up SDL expansions.

我以为我可以使用用 GCC 编译的 devc++,但这个 IDE 有点问题,只是不允许我包含一些头文件。我在设置 SDL 扩展时也遇到了一些问题。

So, is there a way to change VisualStudio compiler to GCC?

那么,有没有办法将 VisualStudio 编译器更改为 GCC?

I really need to stay with VS because it is easy to use and there is a lot of online support.

我真的需要继续使用 VS,因为它易于使用并且有很多在线支持。

采纳答案by Lorenzo Dematté

Short answer: no, you cannot change cl.exe (MS cc compiler) with gcc. Or mingw. (You can with a compatible compiler, like Intel C compiler)

简短回答:不,您不能使用 gcc 更改 cl.exe(MS cc 编译器)。或 mingw。(您可以使用兼容的编译器,例如 Intel C 编译器)

Long answer: you don't need to to that. Use the static linked runtime library, and you don't have a dependency ms dlls anymore (see this answer: How do I make a fully statically linked .exe with Visual Studio Express 2005?)

长答案:你不需要那样做。使用静态链接的运行时库,并且您不再依赖 ms dll(请参阅此答案:如何使用 Visual Studio Express 2005 制作完全静态链接的 .exe?

Or redistribute the VC++ runtime with your app. It's free (http://www.microsoft.com/en-us/download/details.aspx?id=26999)

或者使用您的应用程序重新分发 VC++ 运行时。它是免费的 ( http://www.microsoft.com/en-us/download/details.aspx?id=26999)

回答by Vicky

You don't need to change compiler - they need to download the Visual Studio 2010 redistributable: http://www.microsoft.com/en-gb/download/details.aspx?id=5555

您不需要更改编译器 - 他们需要下载 Visual Studio 2010 可再发行组件:http: //www.microsoft.com/en-gb/download/details.aspx?id=5555

回答by D..

I'm not sure when this became a feature in Visual Studio (probably wasn't one in 2013), but it is now possible to change the "Platform Toolset" - and thus the compiler - used by Visual Studio to other compilers like Clang/LLVM and GCC. I have been happily using Clang with VS2017 ever since the MSVC++ compiler bugged up with some 3rd party libraries.

我不确定这何时成为 Visual Studio 中的一项功能(可能不是 2013 年的一项功能),但现在可以将 Visual Studio 使用的“平台工具集”(以及编译器)更改为其他编译器,例如 Clang /LLVM 和 GCC。自从 MSVC++ 编译器遇到一些 3rd 方库以来,我一直很高兴在 VS2017 中使用 Clang。

Microsoft made a blog poston the installation instructions and how to switch.

微软发表了一篇关于安装说明和如何切换的博客文章

回答by Roger Lipscombe

In short: no. You can't simply use the GCC compiler in Visual Studio.

简而言之:没有。您不能简单地在 Visual Studio 中使用 GCC 编译器。

The long version: you can use a Makefile project to run GCC, but then you lose some of the benefits of using Visual Studio.

长版本:您可以使用 Makefile 项目来运行 GCC,但是您会失去使用 Visual Studio 的一些好处。