天天看点

sublime搭建C/C++语言开发环境

1.下载GCC编译器

下载地址:https://sourceforge.net/projects/mingw/files/latest/download

配置

sublime搭建C/C++语言开发环境
2.3打开sublime > 工具 > 编译系统 > 编译新系统

C

语言编译支持

{
    "cmd": ["gcc","${file}","-o", "${file_path}/${file_base_name}"],
    "file_regex":"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir":"${file_path}",
    "selector": "source.c",
    "encoding":"cp936",
    "variants":
    [
        {
            "name": "C_Run",
            "cmd": ["cmd","/c", "gcc", "${file}", "-o", "${file_path}/${file_base_name}","&&", "cmd", "/c","${file_path}/${file_base_name}"]
        },
        {
            "name":"C_RunInCommand",
            "cmd": ["cmd","/c", "gcc", "${file}","-o","${file_path}/${file_base_name}", "&&","start", "cmd", "/c","${file_path}/${file_base_name} & pause"]
         }
    ]
}
           

C++

编译支持

{
    "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
        }
    ]
}
           
#include <stdio.h>

int main(){

	printf("hello world\n");
	return 0;
}
           
#include <iostream>	// 头文件
using namespace std;	// 命名空间

int main() {	// 主函数
	// 输出语句
	cout << "你好" << endl;
	return 0;
}
           

继续阅读