需要什么软件才能开始在 Windows 中开发 c/c++,无需像 cygwin 或 .Net 这样的额外工具就可以运行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8554293/
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-09-15 18:41:34  来源:igfitidea点击:

What software is needed to start developing c/c++ in windows that would run without additional tools like cygwin or .Net?

c++cwindowscompiler-constructionnative-code

提问by rsk82

I intent to write simple programs in c/c++that would be run in console. I will be writing code in Notepad++ so I do not need an IDE. What I need is a compiler that will produce a standalone EXE file that would run on any 2000/XP/Vista/7system without need for installing VC9/cygwin/MinGW/.Netor other additional libraries.

我打算编写c/c++在控制台中运行的简单程序。我将在 Notepad++ 中编写代码,所以我不需要 IDE。我需要的是一个编译器,它将生成一个独立的 EXE 文件,该文件可以在任何2000/XP/Vista/7系统上运行而无需安装VC9/cygwin/MinGW/.Net或其他附加库。

As far as I understand GCCruns on windows through cygwin, so any app produced by it also needs cygwin1.dllin its presence to run, right ?

据我了解,GCC它在 windows 上运行cygwin,所以它生成的任何应用程序也需要cygwin1.dll在它的存在下运行,对吗?

回答by David Heffernan

Your main options are MSVC and mingw.

您的主要选择是 MSVC 和 mingw。

  • If you want to write C code then avoid MSVC which doesn't have a real C compiler, just a fake wrapper around its C++ compiler. Oh, and the supported dialect is close to C89.
  • If you want to write C++ then MSVC is fine and modern versions have become quite good and reasonably compliant with the standards.
  • If you want to write both C and C++ as per your question then mingw is probably best.
  • 如果您想编写 C 代码,请避免使用没有真正 C 编译器的 MSVC,它只是一个围绕其 C++ 编译器的假包装器。哦,支持的方言接近 C89。
  • 如果您想编写 C++,那么 MSVC 很好,现代版本已经变得非常好并且合理地符合标准。
  • 如果您想根据您的问题编写 C 和 C++,那么 mingw 可能是最好的。

Note that mingw is a native Windows port of the GNU compilers and does not require cygwin. The 32 bit version of mingw is simple to install. If you need to produce 64 bit executables then it's a bit more work to get the 64 bit version of mingw installed. Similarly, if you want the free MS compiler in 64 bit mode you have to do some dirty work to get it installed.

请注意,mingw 是 GNU 编译器的本地 Windows 端口,不需要 cygwin。32 位版本的 mingw 易于安装。如果您需要生成 64 位可执行文件,那么安装 64 位版本的 mingw 需要做更多的工作。同样,如果您想要 64 位模式下的免费 MS 编译器,您必须做一些肮脏的工作才能安装它。

With all of these options you can statically link the runtime to avoid having to deploy a runtime to target machines.

使用所有这些选项,您可以静态链接运行时以避免必须将运行时部署到目标机器。

回答by Keith Nicholas

If you install visual studio express ( even if you aren't going to use it ) you will get the tool chain for building C++ code.

如果您安装 Visual Studio Express(即使您不打算使用它),您将获得用于构建 C++ 代码的工具链。

If you target native code it will run on any windows..... you might want to look at something like WTL to make doing windows a little easier though.

如果您的目标是本机代码,它将在任何窗口上运行..... 您可能想要查看类似 WTL 的东西,以使 Windows 更容易一些。

Also, as per comments, The Platform SDK provides a full compiler toolchain. The other good thing about the SDK is it has a lot of example code for all aspects of the windows API.

此外,根据评论,平台 SDK 提供了完整的编译器工具链。SDK 的另一个好处是它有很多 Windows API 各个方面的示例代码。

回答by patthoyts

The Mingw gcc compiler produces native binaries that only use msvcrt for the C runtime. So that satisfies your requirement. You can go for Visual Studio express but these will require you to ship the version of msvcrt used with your application.

Mingw gcc 编译器生成本机二进制文件,仅将 msvcrt 用于 C 运行时。这样就满足你的要求了。您可以选择 Visual Studio express,但这些将要求您提供与您的应用程序一起使用的 msvcrt 版本。

回答by Alexey Frunze

Open Watcom C/C++may be a good thing for a start, but as far as I understand, it's not up to date with C++ features (most notably in STL it seems) and I'm not even talking about C++11.

Open Watcom C/C++ 刚开始可能是一件好事,但据我所知,它不是最新的 C++ 特性(似乎在 STL 中最显着),我什至没有谈论 C++11。

回答by Ben Voigt

The Visual C++ compiler (included in Visual C++ Express, Visual Studio, and Windows SDK) can produce binaries that don't require any supporting libraries apart from the OS itself. Use static linking. However, the latest versions no longer support Windows versions prior to XP (there are workarounds, but they aren't clean nor recommended for non-trivial applications, best use of the workarounds is when writing an installer program that tests for prerequisites, so it can give meaningful error messages instead of crash).

Visual C++ 编译器(包含在 Visual C++ Express、Visual Studio 和 Windows SDK 中)可以生成除操作系统本身之外不需要任何支持库的二进制文件。使用静态链接。但是,最新版本不再支持 XP 之前的 Windows 版本(有变通方法,但它们不干净也不推荐用于非平凡的应用程序,变通方法的最佳用途是编写测试先决条件的安装程序时,因此它可以给出有意义的错误消息而不是崩溃)。

The MINGW gcc compiler can produce standalone binaries (reliant only on the OS) too.

MINGW gcc 编译器也可以生成独立的二进制文件(仅依赖于操作系统)。

回答by pmg

I've used a MinGW wrapped version of gcc from equation.comthat feels like it's native. Just install that single file and use.

我使用了来自equation.com的 MinGW 包装的 gcc 版本,感觉它是原生的。只需安装该单个文件并使用。