sublime text3 ‘g++‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。

sublime text3 'g++' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

其实我们在安装MinGW过程中 会遇到一些文件提示下载失败,但是不要怂,影响不大,只要完成了下面测试正常

前提:

之后右键电脑->属性->高级系统设置->环境变量,设置path,为path添加你的MinGW的安装目录\bin,比如我的就是C:\MinGW\bin.win + r 输入 cmd ,在dos下输入 g++ -v

 若出现如上,则证明配置成功。

问题描述:
我们这时候先配置相应的

我们首先在sublime上写一个C++小程序:

// 文件名称:test_c_build.c
#include <stdio.h>

int main(int argc, char const *argv[])
{
    printf("hello world!\n");
    return 0;
}

我们直接讲Sublime Text的配置方法

工具 / 编译系统 / 编译新系统(Tools –> Build System –> New Build System)

粘贴下面的代码,保存为C++Build.sublime-build

{
    "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}.exe"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c++",
    "encoding": "cp936",
    
    "shell": true,
    "variants":
    [
        {
            "name": "Run",
            "cmd": ["start","D:/安装软件/CodeBlocks/cb_console_runner.exe","${file_path}/${file_base_name}"]
        }
    ]
}

工具 /用...编译 选Run 那个

....

sublime text3 'g++' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

然后GG了

问题的解决办法:

       在确保了正确执行上述步骤后,以管理员身份运行

解决的灵感来源:

一个错误尝试:

非管理员权限下访问g++ -v报错,也是同样的问题

在管理员身份证下正确运行

同时自己的电脑的subline text并没有调用命令调试器的窗口 需要手动以管理员的身份打开

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
Installing c++/g++ on Windows Disclaimer: This page is being maintained mainly for my students. Use these instructions at your own risk. There is no warranty in any form or shape whatsoever!. There is no guarantee that these instructions are up-to-date. With that understood you may continue with the rest of this page if you choose to accept these terms. This page was last updated on September 13, 2005, but still good as of April 30, 2009. Follow these steps to install g++ (the GNU C++ compiler) for Windows. There is no room for creativity here; you must follow the directions exactly. Pick the drive and a folder in which you want to install g++. I&#39;ll assume that it is C:, but you can choose a different one. If you choose a different drive or a different folder, you&#39;ll need to adapt the directions below accordingly. Download full.exe, an about 14 megabyte executable, to C:\full.exe by right-clicking on the link. Use Save Link As... or Save Target As... Be sure the browser saves the file as C:\full.exe. Run the downloaded executable. This will install g++ (and a lot of other things that you don&#39;t really need) on your hard drive. Go to the C: drive using Windows Explorer and double-click on full.exe. Or, open a DOS window (Start > Programs > Command Prompt), connect to the C: drive using the cd command, and type full. Locate where the bin folder was created for the g++ installation. On my Windows XP machine, it was created in the following path: C:\cygnus\cygwin-b20\H-i586-cygwin32\bin You now should add it to the PATH environment variable. You do that by following: Start -> Control Panel -> System -> Advanced -> Environment Variables At this point you can see the PATH variable either in the User Variables or in the System Variables. Add the g++ path into the PATH variable. You add it to the end of the existing value separated by a semicolon (&#39;;&#39;). Make sure that you do not lose the original value. You are just appending more to the end separated by a semicolon. Restart your computer. A Cygnus Solutions entry will appear in your Programs menu, and an icon may appear on your desktop. Don&#39;t use them! You will use it using the g++ command on a DOS prompt as explained below. You should now be able to run g++ from a DOS (Command Prompt) window. For example, to compile a file called C:\mine\hello.cpp, connect to the C:\mine folder and enter g++ -g hello.cpp -o hello -lm You&#39;ll then be able to run the compiled program by entering hello in the DOS window. If you&#39;ve installed Emacs as described here, you will also be able to run g++ from Emacs. If, when you do this, Emacs tries to compile with the command make -k, you made a mistake during the Emacs installation. If you want to learn how to run g++ on emacs, see here. If you&#39;d like to learn more about where this free compiler came from, we downloaded it from an older site of http://sourceware.org/cygwin/. If you wish to clean up a little, you may delete the file: full.exe at this point. Your g++ compiler is installed under C:\cygnus.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

忆_恒心

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值