Eclipse and Qt Creator uses Visual C++ compiler and Windows SDK

原本想說既然在 Windows 上開發,用 Visual Studio 好了,但打開網站看到價格,呃,我還是繼續用 Eclipse 跟 Qt Creator 吧!謎版?找謎版的時間我都可以處理好了…

Install Windows SDK

安裝 Windows 7 的。

Microsoft Windows SDK for Windows 7 and .NET Framework 4

Troubleshooting

裝 Windows SDK 失敗,像這篇的狀況。移掉 Microsoft Visual C++ 2010 redistributable packages 後再裝 Windows SDK 就可以了。

compile 時遇到 error C2059: syntax error : 'constant'patch

Eclipse

Install CDT Visual C++ Support

在 Eclipse 裝 CDT Visual C++ Support,才有 Visual C++ tool chain。我的 Eclipse 是 Juno。

CDT site:http://download.eclipse.org/tools/cdt/releases/juno

Configuration

Project property

C/C++ Build -> Tool Chain Editor 的 toolchain 設為 Microsoft Visual C++。

C/C++ Build -> Environment 增加 PATH C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin,這樣才找得到 Visual C++ compiler。

C/C++ General -> Paths and Symbols -> Includes -> GNU C++

Eclipse Configuration

Qt Creator

因為想到要有 GUI 介面,所以需要 Qt + Windows SDK,但現在 Eclipse 跟 Qt 的整合不太好,改用 Qt Creator + Windows SDK。

直接裝 Qt 5.3.1 for Windows 32-bit (VS 2010, OpenGL, 537 MB)

Kits

如果已經先裝其他版本的 Qt,應該可以在選項裡加 Kit:

Qt Creator Windows SDK Kits

pro setting

INCLUDEPATH 要加 Windows SDK 的路徑,如 Eclipse Configuration 圖中的路徑。

Troubleshooting

compile 時遇到 LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt 的錯誤。

Solution:http://qt-project.org/wiki/Category:Tools::msvc