剛開始的時候圖省事,直接下載了1.3G的 Qt SDK 完整開發環境下來安裝,結果就出問題了:學習開發自定義控件時安裝不上,提示:The plugin' 'uses incompatible Qt library.Expected build key"windows msve release full-config",got"windows mingw debug"
關於這個錯誤,官方說:
The version of QT Creator shipped with the QT SDK Open Source version for windows is build using Visual Studio, whereas the SDK is build with and supports g++ (MinGW). This doesn’t cause too many problems, but it totally defeats building and installing QT Designer plugins into QT Creator. The error message is:
也就是說,QtCreator是用Visual Studio編譯的,但QtCreator的編譯器是MinGW,編譯出來的控件自然就加載不到QtCreator上了。
網上說解決方法有三種:
1) Build QT Creator from source with MinGW
2) Build the plugin with Visual Studio
3) Build QT Creator with build key checking turned off.
我就選擇了第一種:自己編譯安裝QtCreator。
1、下載
qt-win-opensource-4.8.2-mingw.exe
2、把MinGW-gcc440_1.zip解壓到C盤,然後安裝qt-win-opensource-4.8.2-mingw.exe,接着把 C:\mingw\bin 添加到系統環境變量。
3、下載QtCreator的源文件包qt-creator-2.3.0-src.zip,把壓縮包裏面的東西都解壓取文件夾D:\qt-creator,此時的目錄結構應該是D:\qt-creator\qtcreator.pro
4、編譯安裝QtCreator:新建一個目錄 D:\QtCreator(注意這裏跟前面的qt-creator不同),再把以下內容複製到一個新建的批處理文件
- qmake "CONFIG+=release"
- make
- nmake INSTALL_ROOT="D:\QtCreator" install
把批處理文件保存到 D:\qt-creator,雙擊運行。
5、批處理成功執行後,把 D:\qt-creator\bin 裏面的dll文件複製到 D:\QtCreator\bin ,如果可以雙擊運行 D:\QtCreator\qtcreator.exe,說明QtCreator安裝編譯成功!
接下來還要對開發環境進行相應的設置,留到下一章再說...