安裝
基本流程:下載一個編譯器,然後設置系統環境變量,下載sublime,配置編譯文件。
安裝Sublime
- 略過
安裝MinGW
下載安裝後打開,然後選擇想要的編譯器
然後選擇Installation
->Apply Changes
,可能會失敗多試幾次。環境變量
- 安裝成功測試:win R
->cmd
->g++ -v
,如圖則是成功:
編譯器配置
Sublime:Tools
->build system
->New build system
黏貼下面代碼,ctrl s
保存成C++Build.sublime-build
文件,然後就可以在編譯系統裏面看到新建的C++Build編譯器,選擇這個就可以運行了。ctrl shift B
選擇第二個選項。
`
{
"encoding": "utf-8",
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall -std=c++11 \"$file_name\" -o \"$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c++",
"variants":
[
{
"name": "Run in sublime",
"shell_cmd": "g++ -Wall -std=c++11 \"$file_name\" -o \"$file_base_name\" && cmd /c \"${file_path}/${file_base_name}\""
},
{
"name": "CMD Run",
"shell_cmd": "g++ -Wall -std=c++11 \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}
For gcc
{
"cmd": ["gcc", "${file}", "-o", "${file_path}/${file_base_name}.exe", "-std=c99"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c++",
"encoding": "utf-8",
"shell": true,
"variants":
[
{
"name": "Run in sublime",
"shell_cmd": "gcc -Wall -std=gnu99 \"$file_name\" -o \"$file_base_name\" && cmd /c \"${file_path}/${file_base_name}\""
},
{
"name": "CMD Run",
"shell_cmd": "gcc -Wall -std=gnu99 \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}
- Over