问题描述
我试图从命令行编译c ++程序,但我不能。我尝试了的所有步骤和说明。
我安装了MinGW,但是我在安装的最后一步遇到困难,它解释了如何更改环境路径。在环境变量中没有PATH的一部分,当我尝试添加它或甚至编辑系统变量中的一个时,编译不起作用(当我在命令提示符中键入g ++时,没有任何东西出现)。
我在网上搜索解决方案,但是我一直找不到任何东西。
重新安装MinGW32解决了无法编译C ++的问题。
添加; C:\mingw\bin
在PATH变量下,在我的电脑中的属性中的高级设置中修复了在cmd中编译的问题,正如@Chrono Kitsune所回答的。
按打开运行对话框,然后键入
sysdm.cpl,3
PATH
变量,请点击新建按钮,然后点击新建按钮。为变量名键入 PATH
。否则,只需双击现有的 PATH
变量。现在,将以下内容添加到变量值的末尾: ; C:\mingw\bin
其中 C:\mingw\bin
是包含 g ++。exe $的文件夹c $ c>。
g ++。exe -xc -E nul
如果您仍然遇到错误,请尝试注销并重新登录。
I'm trying to compile c++ programs from the commandline, but I can't. I tried all the steps and instructions listed here.
I got MinGW installed, but I get stuck in the last step of the installation that explains how to change environment paths. There simply isn't PATH part of it on the environment variables, and when I try to add it or even edit the one in System variables, compiling doesn't work (nothing comes up when I type g++ on the command prompt).
I've searched online for solutions, but I haven't been able to find anything.
Reinstalling MinGW32 resolved the issue of not being able to compile C++ at all.
Adding ;C:\mingw\bin
in the PATH variable under Advanced Settings in Properties in My Computer fixed compiling in cmd, as answered by @Chrono Kitsune.
Press to open the Run dialog and type
sysdm.cpl ,3
- Click the "Environment Variables" button.
- There are two sections: "User Variables" (top) and "System Variables" (bottom). You want to look at the top section.
- If you don't have a
PATH
variable, click the "New" button and typePATH
for the variable name. Otherwise, just double-click the existingPATH
variable. Now add the following to the end of the variable's value:
;C:\mingw\bin
where
C:\mingw\bin
is the folder containingg++.exe
.- Click OK on each dialog box to close it.
Open a new command prompt and try to execute
g++.exe -xc -E nul
If you still get an error, try logging off and logging back on.
这篇关于在Windows 8上使用MinGW在cmd中编译C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!