Windows 8使用Mingw在cmd中编译c ++ [英] Windows 8 Compiling c++ in cmd using Mingw

查看:297
本文介绍了Windows 8使用Mingw在cmd中编译c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从命令行编译c ++程序,但我不能。我尝试了这里列出的所有步骤和说明



我安装了Mingw,但是在安装的最后一步,我解决了如何更改环境路径。在环境变量上根本没有PATH部分,当我尝试添加它,甚至编辑系统变量中的一个时,编译不起作用(当我在命令提示符下键入g ++时没有任何东西)。

我已经在线搜索解决方案,但我还没有找到任何东西。



编辑:重新安装mingw32解决了无法编译c ++的问题。



在cmd中的属性中的高级设置下的PATH变量中添加; C:\mingw \bin在cmd中固定编译,由@Chrono Kitsune


解决方案


  1. Win + R 类型

      sysdm.cpl,3 

    li>

  2. 点击环境变量按钮。

  3. 有两个部分:用户变量(顶部)和系统变量

  4. 如果您没有 PATH 变量,请点击新建按钮,对变量名称键入 PATH 。否则,只需双击现有的 PATH 变量。

  5. 现在将以下内容添加到变量值的末尾:

     ; C:\mingw\bin 

    其中 C:\mingw\bin 是包含 g ++。exe

  6. 打开一个新的命令提示符,然后单击<确定>按钮。尝试执行

      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 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

解决方案

  1. Press Win+R to open the Run dialog and type

    sysdm.cpl ,3
    

  2. Click the "Environment Variables" button.
  3. There are two sections: "User Variables" (top) and "System Variables" (bottom). You want to look at the top section.
  4. If you don't have a PATH variable, click the "New" button and type PATH for the variable name. Otherwise, just double-click the existing PATH variable.
  5. Now add the following to the end of the variable's value:

    ;C:\mingw\bin
    

    where C:\mingw\bin is the folder containing g++.exe.

  6. Click OK on each dialog box to close it.
  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆