g++ 无法在 Windows 命令提示符下工作。 已安装 Cygwin

发布于 2024-07-14 11:52:37 字数 737 浏览 6 评论 0原文

我已经安装了 Eclipse 和 CDT(在 Eclipse 中使用 C/C++ 需要 CDT),并安装了 Cygwin,以便我可以编译我的文件。

在环境变量中,我将路径设置为包含以下内容:“C:\cygwin\bin;”

g++、make 和 GDC 都是通过 Cygwin 安装的。 我通过在 bin 文件夹中搜索它们来确保这一点 - 它们都在那里。

如果我在 Windows 命令提示符中输入“make”,则会出现以下内容:

make: *** No targets specified and no makefile found.  Stop.

如果我在 Windows 命令提示符中输入“g++”或“gdc”,则会出现以下内容(或类似内容):

'g++' is not recognized as an internal or external command,
operable program or batch file.

所以,换句话说,make 正在工作,但其余部分则不起作用不是..但它们位于同一个 bin 文件夹中! 让我完全困惑了。

如果我尝试打开 Cygwin Bash Shell,g++、make 和 GDC 都可以在那里工作。

但是,我需要它在命令提示符下工作,以便 Eclipse 能够编译我在 IDE 中编写的程序。

如果您知道为什么会发生这种情况,请告诉我。

I have installed Eclipse and CDT (to use C/C++ in eclipse CDT is needed), as well as installing Cygwin so that I can compile my files.

In environment variables I've set Path to include the following: "C:\cygwin\bin;"

g++, make and GDC are all installed via Cygwin. I made sure of this by searching for them in the bin folder - they're all there.

If I enter "make" into the windows command prompt, this appears:

make: *** No targets specified and no makefile found.  Stop.

If I enter "g++" or "gdc" into the windows command prompt, this appears (or similar):

'g++' is not recognized as an internal or external command,
operable program or batch file.

So, in other words make is working but the rest isn't..but they're in the same bin folder! Has got me completely confused.

If I attempt to open Cygwin Bash Shell, g++, make and GDC all work there.

However, I need it to work in the command prompt so that Eclipse is able to compile the programs I write in the IDE.

If you know why this is happening, please let me know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

作业与我同在 2024-07-21 11:52:37

我没有太多使用 cygwin,但我的理解是您必须从 cygwin bash shell 使用它。

如果你需要 g++、make 等,请使用 mingw,有了它,g++ 就可以在普通的 Windows 命令行中工作。

I haven't used cygwin much, but my understanding is you have to use it from the cygwin bash shell.

if you need g++, make, etc, use mingw, with it, g++ works from the normal windows command line.

迷乱花海 2024-07-21 11:52:37

这是发生在我身上的事情以及我如何解决它。
我的 C:\cygwin\bin\g++.exe 是指向 C:\etc\alternatives\g++.exe 的快捷方式,它又指向 C:\cygwin\bin\g++-3.exe。
用 g++-3 替换 g++ 对我有用。

Here is what happened to me and how I fixed it.
My C:\cygwin\bin\g++.exe is a shortcut pointing to C:\etc\alternatives\g++.exe, which points back to C:\cygwin\bin\g++-3.exe.
Replacing g++ with g++-3 worked for me.

心清如水 2024-07-21 11:52:37

在C:\cygwin\bin中查看是否有g++.exe。 如果没有,则安装未正确完成,您可能需要重新安装。 这就是我的问题,已经解决了:)

In C:\cygwin\bin see whether g++.exe is there. If not, the installation wasn't done properly and you may need to install again. That's what was my problem and it's resolved :)

私藏温柔 2024-07-21 11:52:37

将 cygwin 路径添加到 Path 变量对我有用(Windows 8.1 64 位):

转到系统属性并选择高级系统属性

转到环境变量并选择系统变量中的 Path,单击编辑

添加 Cygwin 路径...
对于 32 位:

C:\Cygwin\bin;C:\Cygwin\usr\bin

对于 64 位:

C:\Cygwin64\bin;C:\Cygwin64\usr\bin

Adding the cygwin paths to the Path variable worked for me (windows 8.1 64 bit):

Go to system properties and select advanced system properties

Go to environment variables and select Path in system variables, click edit

Add the Cygwin paths...
for 32 bit:

C:\Cygwin\bin;C:\Cygwin\usr\bin

for 64 bit:

C:\Cygwin64\bin;C:\Cygwin64\usr\bin
瀟灑尐姊 2024-07-21 11:52:37

CMD 窗口中,尝试输入 bash 以在该窗口中启动 bash shell。 如果这不起作用,则 cygwin bin 目录不在您的路径上。

如果它确实有效,请输入类型 g++类型 make 以查看这些命令所使用的路径。 我很确定你的问题出在你的 PATH 变量上。

In the CMD window, try typing bash to start a bash shell in that window. If that doesn't work, then the cygwin bin directory is not on your path.

If it did work, enter type g++ and type make to see the paths that are being used for these commands. I'm pretty sure your problem is with your PATH variable.

白馒头 2024-07-21 11:52:37

您可以安装 Windows 版本,以获取一些帮助来准确找出哪些可执行文件正在运行。

也许它从完全不同的地方获取“make”,并且您对 %PATH% 的添加不起作用。

还可以通过在看到问题的同一命令提示符窗口中键入 echo %path% 来验证它,只是为了确定。

You could install a Windows version of which to get some help in figuring out exactly which executables are being run.

Perhaps it's picking up 'make' from somewhere completely different, and your addition to %PATH% is not working.

Also verify it by typing echo %path% in the same command prompt window as you're seeing the problem in, just to make sure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文