Windows 8使用Mingw在cmd中编译c ++ [英] Windows 8 Compiling c++ in cmd using Mingw
问题描述
我试图从命令行编译c ++程序,但我不能。我尝试了这里列出的所有步骤和说明
我安装了Mingw,但是在安装的最后一步,我解决了如何更改环境路径。在环境变量上根本没有PATH部分,当我尝试添加它,甚至编辑系统变量中的一个时,编译不起作用(当我在命令提示符下键入g ++时没有任何东西)。
我已经在线搜索解决方案,但我还没有找到任何东西。
编辑:重新安装mingw32解决了无法编译c ++的问题。
在cmd中的属性中的高级设置下的PATH变量中添加; C:\mingw \bin在cmd中固定编译,由@Chrono Kitsune
-
按 Win + R 类型
sysdm.cpl,3
li>
- 点击环境变量按钮。
- 有两个部分:用户变量(顶部)和系统变量
- 如果您没有
PATH
变量,请点击新建按钮,对变量名称键入PATH
。否则,只需双击现有的PATH
变量。 - 现在将以下内容添加到变量值的末尾:
; C:\mingw\bin
其中
C:\mingw\bin
是包含g ++。exe $
-
打开一个新的命令提示符,然后单击<确定>按钮。尝试执行
g ++。exe -xc -E nul
$ p
如果您仍然遇到错误,请尝试注销
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 do add it or even edit the one in System variables compiling doesn't work (nothing comes up when I type g++ in command prompt).
I've searched online for solutions but I haven't been able to find anything.
EDIT: 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 Win+R 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 ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!