sublime text 3搭建/配置C++編譯環境
阿新 • • 發佈:2019-01-06
配置
機房渣渣win7 32bit
Mingw
sublime text 3
下載Mingw
下載連結這裡 密碼vq8n
這只是一個下載器,下載完之後執行,
選中我那些帶綠色的,右鍵—>Mark for Installation
然後左上角Installation—>Apply Changes—>Apply
然後就開始下載了。
下載完之後我們就有了C++的編譯器(小白不知道是哪個所以看著像的都下了)
為了方便我們需要把它放入環境變數。
放在path目錄下
注意前後都需要一個英文分號
然後我們需要測試是否成功
開啟cmd,輸入g++ -v
如果出現
那麼恭喜你成功了
然後我們就可以用cmd來進行C++程式碼的編譯
在當前目錄開啟cmd,輸入命令
g++ 檔名.cpp -o 檔名
配置sublime text 3
首先你需要一個sublime text 3密碼fcui
然後點這裡
(不要問我漢化包哪裡來的)
刪掉原來的程式碼,輸入以下程式碼
{
"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": "build",
"shell_cmd": "g++ \"$file\" -o \"$file_base_name\" -g"
},
{
"name": "Run",
"shell_cmd": "g++ \"$f ile\" -o \"$file_base_name\" -g && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
},
{
"name": "Run Full Stack",
"shell_cmd": "g++ \"$file\" -o \"$file_base_name\" -Wl,--stack=268435456 && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
},
{
"name": "Run with o2",
"shell_cmd": "g++ \"$file\" -o \"$file_base_name\" -Wl,--stack=268435456 && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}
儲存在Sublime Text 3\Packages\User下面,命名為C++.sublime-build
然後你就能看到像我那樣的C++編譯器了
Ctrl+Shift+b編譯執行