天天看点

windows sublime text3编译运行c一:mingw二 powershell中运行(推荐)

windows sublime text3编译运行c

  • 一:mingw
  • 二 powershell中运行(推荐)
    • 1.配置sublime-build
    • 2.编译运行

一:mingw

由于安装过程中出现无法连接,网上找的一些方法在此。

但转念一想,powershell里不就有gcc吗?!

windows sublime text3编译运行c一:mingw二 powershell中运行(推荐)

具体该种方法不再赘述,感兴趣的小伙伴可以点此链接

二 powershell中运行(推荐)

既然可以在cmd中运行,那么可不可以改成在powershell里运行呢?

**最大的好处在于:不用再下其他东西了 ***2333 *

参考StackOverflow

1.配置sublime-build

打开sublime text 3

Tools->build system->new build system

输入如下代码

{
    "cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
    "shell": true,

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["start", "powershell", "-NoExit", "${file_path}//${file_base_name}.exe"],
            "shell": true
        }
    ]
}
           

ctrl+s保存(打开即为默认路径

windows sublime text3编译运行c一:mingw二 powershell中运行(推荐)

2.编译运行

写好的c文件 保存 并ctrl + B

或ctrl shift b 选择模式:

windows sublime text3编译运行c一:mingw二 powershell中运行(推荐)

c_power -run:编译并在powershell中运行

c_power : 编译生成exe文件不运行

windows sublime text3编译运行c一:mingw二 powershell中运行(推荐)

继续阅读