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

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

转载于:https://www.cnblogs.com/chendl111/p/7630129.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值