一、安裝GCC編譯器,我安裝的是tdm64-gcc-5.1.0-2。
下載鏈接:
http://tdm-gcc.tdragon.net/download
二、配置Sublime的Build配置文件。
1, 打開Sublime Text,點擊Tools->Build System->New Build System
2, 輸入以下內容
{
"cmd": ["g++", "-Wall","-fexceptions", "-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++",
"encoding":"cp936",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/c", "g++", "-Wall","-fexceptions", "-g", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}",
"&&", "cmd", "/c", "${file_path}/${file_base_name}"
]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/c", "g++","-Wall","-fexceptions", "-g", "-std=c++11","${file}", "-o", "${file_path}/${file_base_name}",
"&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"
]
}
]
}
保存爲NewC++.sublime-build
該文件位置:Sublime Text 2.0.2 x64\Data\Packages\User
3, 選定Tools->Build System->NewC++
在C++源文件中按Ctrl+B編譯,Ctrl+Shift+B執行。
搞定。