首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> C++ >> C++ 入門

Ubuntu 12.04 下 Eclipse 配置 C++11 開發環境全攻略

     編輯:C++ 入門

安裝 GCC 4.8(支援 C++11 的最低版本)

Ubuntu 12.04 預設倉庫 GCC 版本較舊,需加入 Toolchain PPA:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
g++ --version  # 驗證版本

配置 Eclipse 全域/專案編譯參數

  1. 選單 Project → Properties → C/C++ Build → Settings → Miscellaneous
  2. 在 Other flags 加入 -std=c++11
  3. 若僅針對單一專案,右鍵專案 → Properties 同樣路徑設定

配置 CDT Indexer 正確解析 C++11 語法

此步驟讓編輯器正確識別 auto、lambda、nullptr 等關鍵字:

  1. Project → Properties → C/C++ General → Preprocessor Include Paths, Macros etc.
  2. 切換到 Providers 標籤
  3. Configuration 選 Debug(Release 同理再做一次)
  4. 勾選 CDT GCC Built-in Compiler Settings
  5. 取消勾選 Use global provider shared between projects
  6. 在 Command to get compiler specs 後追加 -std=c++11
  7. Apply → OK
  8. 最後 Project → C/C++ Index → Rebuild 重建索引

參考資源

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved