sublime text3安装配置c++环境(windows+ubuntu)

时间:2022-05-03 04:06:26

1.下载sublime text3

官网地址:http://www.sublimetext.com/3
ubuntu直接在Ubuntu Software中搜索sublime安装

2.配置环境变量(windows)

下载Mingw放到C盘,path路径设为`C:\MinGW\bin`
在cmd中输入`g++ -v`或`gcc -v`判断路径是否设置成功,path路径在电脑重启后生效

3.设置package control

在控制台中加入一下网址的代码
https://packagecontrol.io/installation

4.配置编译运行文件

在windows下的编译配置文件(支持c++11)

{
"encoding": "cp936",
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall -std=c++11 -fexec-charset=GBK $file_name -o $file_base_name",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c++", "variants":
[
{
"name": "Run",
"shell_cmd": "g++ -Wall -fexec-charset=utf-8 \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}

用c编译的话只需用gcc替换上述代码的g++即可`

在ubuntu下的编译配置文件(支持c++11)

{
"shell_cmd": "g++ '-std=c++11' '${file}' -o '${file_path}/${file_base_name}'",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++", "variants":
[
{
"name": "Build & Run",
"shell_cmd": "x-terminal-emulator -e bash -c \"g++ '-std=c++11' '${file}' -o '${file_path}/${file_base_name}' ; '${file_path}/${file_base_name}' ; read -p '\nPress ENTER or type command to continue...'\""
}, {
"name": "Build Only",
"shell_cmd": "g++ '-std=c++11' '${file}' -o '${file_path}/${file_base_name}'"
}, {
"name": "Run Only",
"shell_cmd": "x-terminal-emulator -e bash -c \"'${file_path}/${file_base_name}' ; read -p '\nPress ENTER or type command to continue...'\""
}
]
}

5.参考

https://www.cnblogs.com/kearon/p/7354888.html