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)html

{
    "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++便可`c++

在ubuntu下的編譯配置文件(支持c++11)shell

{ 
    "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
相關文章
相關標籤/搜索