【问题标题】:Error compiling simple C program using Cygwin, cmd and Sublime Text 2使用 Cygwin、cmd 和 Sublime Text 2 编译简单 C 程序时出错
【发布时间】:2015-03-22 22:04:18
【问题描述】:

我在 Windows 7 中安装了 Cygwin。然后我将环境变量设置为路径“C:\cygwin\bin”,但是当我尝试构建一个简单的“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");
}

如何解决?

【问题讨论】:

  • cygwin 使用 /cygdrive 作为在文件名中指定驱动器的替代方法...例如: /cygdrive/c/programs/helloworld.c 用于您的程序。或者,如果该文件位于 cygwin 安装树中,那么您可以将其相对于 cygwin 的安装位置指定为 root。
  • 你安装了 gcc/g++ 吗?
  • 好的...我想我在安装过程中错过了选择软件包.....现在有人可以指导我如何卸载 Cygwin 吗?
  • 你不需要卸载它...只需重新运行你最初运行的安装程序(setup-x86.exe或setup-x86_64.exe)...当你得到到软件选择屏幕,选择 gcc...它们将被添加到您的安装中。
  • 谢谢老兄...照你说的做...很快就会更新这篇文章!

标签: c build cmd cygwin sublimetext2


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-21
    • 2012-08-02
    • 1970-01-01
    • 2013-01-15
    • 2018-02-03
    • 2020-05-24
    • 1970-01-01
    • 2013-12-28
    相关资源
    最近更新 更多