使用sublime text 3 搭建輕量級C/C++編輯/編譯器

來源:互聯網
上載者:User

標籤:

0x01.軟體準備: 

 

sublime text 3

MinGW

 

0x02.安裝 & 配置 MinGW: 


path變數添加一條 C:\MinGW\bin

注意,這裡配置之後需要重啟生效,但有辦法可以強制生效: 

set path=C:/MinGW/bin;%PATH%; 

驗證變數設定成功與否:

mingw-get //如果出現MinGW介面則設定成功

安裝g++

mingw-get install gcc g++

驗證g++安裝成功與否:

g++ -v //列印出g++版本資訊,說明安裝成功

 

0x03.配置Sublime text 3

開啟Tools->Build System->New Build System,鍵入如下資訊:

{    "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",    "working_dir": "${file_path}",    "selector": "source.c, source.c++",    "variants":    [        {            "name": "Run",            "cmd": ["cmd", "/c", "g++", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", "${file_path}/${file_base_name}"]        },        {            "name": "RunInCommand",            "cmd": ["cmd", "/c", "g++", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & pause"]        }    ]}

Ctrl+S之後會提示儲存,請保證檔案名稱的格式為 “XXX.sublime-build” 
XXX表示隨意,我改成了“c++.sublime-build” 
這一步完成之後,在Build System裡面選中你剛剛儲存的方案,即c++

隨後在,Preferences->Key Bindings - User,可填入如下方案:

{ "keys": ["ctrl+alt+B"], "command": "build", "args": {"variant": "RunInCommand"} }

這裡你可以自由修改啟動並執行快速鍵。

0x04.使用注意 
C/C++的源檔案必須在全英文的目錄下運行!

 

0x05.END

 

使用sublime text 3 搭建輕量級C/C++編輯/編譯器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.