C语言 如何在 Windows 7 中编译 C 程序?

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

How to compile C programming in Windows 7?

cwindows-7

提问by Mohd Isa

I am looking for free tools to compile C programs on Windows 7. I've always compiled C code on Ubuntu using gcc in the past. So, how can I compile C code on Windows 7? Please teach me. :)

我正在寻找在 Windows 7 上编译 C 程序的免费工具。我过去一直使用 gcc 在 Ubuntu 上编译 C 代码。那么,如何在 Windows 7 上编译 C 代码?请教我。:)

回答by Cody Gray

MinGWuses a fairly old version of GCC (3.4.5, I believe), and hasn't been updated in a while. If you're already comfortable with the GCC toolset and just looking to get your feet wet in Windows programming, this may be a good option for you. There are lots of great IDEs available that use this compiler.

MinGW使用相当旧的 GCC 版本(我相信是 3.4.5),并且已经有一段时间没有更新了。如果您已经熟悉 GCC 工具集,并且只是想在 Windows 编程中涉足,那么这对您来说可能是一个不错的选择。有很多很棒的 IDE 可以使用这个编译器。

Edit:Apparently I was wrong; that's what I get for talking about something I know very little about. Tauran points out that there is a project that aims to provide the MinGW toolkit with the current version of GCC. You can download it from their website.

编辑:显然我错了;这就是我谈论一些我知之甚少的事情时得到的结果。Tauran 指出,有一个项目旨在为 MinGW 工具包提供当前版本的 GCC。你可以从他们的网站下载。


However, I'm not sure that I can recommend it for serious Windows development. If you're not a idealistic fanboy who can't stomach the notion of ever using Microsoft software, I highlyrecommend investigating Visual Studio, which comes bundled with Microsoft's C/C++ compiler. The Express version(which includes the same compiler as all the paid-for editions) is absolutely free for download. In addition to the compiler, Visual Studio also provides a world-class IDE that makes developing Windows-specific applications much easier. Yes, detractors will ramble on about the fact that it's not fully standards-compliant, but such is the world of writing Windows applications. They're never going to be truly portable once you include windows.h, so most of the idealistic dedication just ends up being a waste of time.


但是,我不确定是否可以将其推荐用于严肃的 Windows 开发。如果您不是一个无法忍受使用 Microsoft 软件的理想主义粉丝,我强烈建议您研究Visual Studio,它与 Microsoft 的 C/C++ 编译器捆绑在一起。该快递版本(包括相同的编译器为所有付费版本)是完全免费的下载。除了编译器之外,Visual Studio 还提供了世界一流的 IDE,使开发特定于 Windows 的应用程序变得更加容易。是的,批评者会喋喋不休地说它不完全符合标准,但这就是编写 Windows 应用程序的世界。一旦你包含它们,它们就永远不会真正便携windows.h,所以大多数理想主义的奉献最终只是浪费时间。

回答by joce

Microsoft Visual Studio Express

微软 Visual Studio Express

It's a full IDE, with powerful debugging tools, syntax highlighting, etc.

它是一个完整的 IDE,具有强大的调试工具、语法高亮等。

回答by demoslam

If you are familiar with gcc, as you indicated in the question, you can install MinGW, which will set a linux-like compile environment in Win7. Otherwise, Visual Studio 2010 Express is the best choice.

如果你熟悉gcc,正如你在问题中所指出的,你可以安装MinGW,它将在Win7中设置一个类似linux的编译环境。否则,Visual Studio 2010 Express 是最佳选择。

回答by BiGYaN

You can get MinGW (as others have suggested) but I would recommend getting a simple IDE (not VS Express). You can try Dev C++ http://www.bloodshed.net/devcpp.htmlIts a simple IDE for C/C++ and uses MinGW internally. In this you can write and compile single C files without creating a full-blown "project".

您可以获得 MinGW(正如其他人所建议的),但我建议您获得一个简单的 IDE(而不是 VS Express)。你可以试试 Dev C++ http://www.bloodshed.net/devcpp.html它是一个简单的 C/C++ IDE,内部使用 MinGW。在这里,您可以编写和编译单个 C 文件,而无需创建完整的“项目”。

回答by Web Developer in Pune

Compiling Programs on Windows 7:

在 Windows 7 上编译程序:

You have to download configured Borland Compiler from http://www.4shared.com/get/Gs41_5yA/borland_for_graphics.htmlor http://dwij.co.in/graphics-c-programming-for-windows-7-borland-compiler/.

您必须从http://www.4shared.com/get/Gs41_5yA/borland_for_graphics.htmlhttp://dwij.co.in/graphics-c-programming-for-windows-7-borland-下载配置的 Borland Compiler编译器/

Put your Borland's ‘bin' folder into Environmental Variables.
Now go inside folder ‘bin' & edit file bcc32.cfg as per your folder structure. This file contains settings of headers & libraries.

将您的 Borland 的“bin”文件夹放入环境变量中。
现在进入文件夹“bin”并根据您的文件夹结构编辑文件 bcc32.cfg。该文件包含头文件和库的设置。

-I"D:\Borland\include;"
-L"D:\Borland\lib;D:\Borland\Lib\PSDK"

Now create any C/C++ Program say myprogram.cpp
Use following command to compile this bunch of code:

现在创建任何 C/C++ 程序说 myprogram.cpp
使用以下命令来编译这堆代码:

F:\>bcc32 myprogram.cpp

回答by Aamir

Get gcc for Windows . However, you will have to install MinGW as well.

获取适用于 Windows 的 gcc。但是,您还必须安装 MinGW。

You can use Visual Studio 2010 express edition as well. Link here

您也可以使用 Visual Studio 2010 快速版。链接在这里