使用 Cygwin、cmd 和 Sublime Text 2 编译简单 C 程序时出错

Error compiling simple C program using Cygwin, cmd and Sublime Text 2

我在 Windows 7 中安装了 Cygwin。然后我将环境变量设置为路径 "C:\cygwin\bin",但是当我尝试 build 一个简单的 "helloworld.c" 文件,它显示以下内容:

[Error 2] The system cannot find the file specified
[cmd:  [u'g++', u'C:\programs\helloworld.c', u'-o', u'C:\programs/helloworld']]
[dir:  C:\programs]
[path: C:\cygwin\bin;C:\cygwin\bin;C:\cygwin\bin;C:\TC\BIN]
[Finished]

而我写的代码如下:

#include <stdio.h>

main()
{
    printf("Hello, world\n");
}

如何解决?

安装所有开发包,因为在不久的将来您将需要其中的一些。

为此使用 setup-x86.exe(或 64 位系统上的 setup-x86_64.exe),因为这是通过 Cygwin 安装包的方式。如果您没有该可执行文件,请再次下载它(这是用于安装 Cygwin 的那个)。

请记住使用正确的格式,因为在末尾的 cmd 行中您写的是 /helloworld 而不是 \helloword。