Windows下配置Sublime C/C++編譯器
阿新 • • 發佈:2018-12-09
安裝
基本流程:下載一個編譯器,然後設定系統環境變數,下載sublime,配置編譯檔案。
安裝Sublime
- 略過
安裝MinGW
下載安裝後開啟,然後選擇想要的編譯器 然後選擇
Installation
->Apply Changes
,可能會失敗多試幾次。環境變數
- 安裝成功測試:win R
->cmd
->g++ -v
,如圖則是成功:
編譯器配置
Sublime:Tools
->build system
->New build system
黏貼下面程式碼,ctrl s
儲存成C++Build.sublime-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