correct build step for qt standalone application in windows

建置可獨立執行的Qt程式 ......

要建置獨立的qt exe在windows很複雜,
因為要編譯qt static linking library,
而根據不同compiler有兩種MinGW與msvc兩種版本.

首先,參考這一篇文章:
roymercadian.blogspot.tw/2013/01/qt.html



但不同的是我使用的是最新的QT 5.1.1
結果卻是失敗的,他回應的訊息是

只好想別的辦法....

似乎跟opengl 與angle有關係,於是在參考這篇文章:
http://www.hnmade.com/bbs/thread-12527-1-1.html

原來少了-opengl desktop
但nmake還是出現錯誤:(真的是無言....)

再想辦法解決吧...(求助google大神....)

有個人說:
http://blog.csdn.net/llambkin/article/details/8977163
configure 參數可能有錯:
於是我改為:
configure -prefix c:\qt511-static -release -platform win32-msvc2010 -c++11  -icu -opengl desktop -qt-sql-sqlite -qt-zlib -qt-style-windowsvista -qt-libpng -qt-libjpeg -nomake demos -nomake examples -nomake tests -mp


再試試看..還是失敗
改參數:
C:\Qt\qt-everywhere-opensource-src-5.1.1>configure -prefix c:\qt511-static -release -static -platfor
m win32-msvc2010 -c++11 -no-icu -opengl desktop -qt-sql-sqlite -qt-zlib -qt-libpng -qt-libjpeg -noma
ke examples -nomake tests -mp

再試試看....
 
還是失敗......出現...
qplatformopenglcontext.cpp
c:\qt\qt-everywhere-opensource-src-5.1.1\qtbase\include\qtgui\../../src/gui/opengl/qopengl.h(82) : f
atal error C1083: 無法開啟包含檔案: 'GLES2/gl2.h': No such file or directory
qopenglcontext.cpp
c:\qt\qt-everywhere-opensource-src-5.1.1\qtbase\include\qtgui\../../src/gui/opengl/qopengl.h(82) : f
atal error C1083: 無法開啟包含檔案: 'GLES2/gl2.h': No such file or directory

無言中.....
然後再google,這個人跟我發生一樣的問題
http://www.qtcentre.org/threads/53752-Error-compiling-qt5-01-on-windows

再次改用configure
C:\Qt\qt-everywhere-opensource-src-5.1.1>configure -prefix c:\qt511-static -release -static -platfor
m win32-msvc2010 -c++11 -no-icu -opengl desktop -qt-sql-sqlite -qt-zlib -qt-libpng -qt-libjpeg -noma
ke examples -nomake tests -mp -nomake demos -skip qtwebkit -no-qml-debug -no-angle

結果...
        link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:
type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144cc
f1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:..\..\..\bin\rcc.exe.embed.man
ifest /OUT:..\..\..\bin\rcc.exe @C:\Windows\Temp\nmB879.tmp
LINK : fatal error LNK1104: 無法開啟檔案 '..\..\..\bin\rcc.exe'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\link.EXE"' : 傳回
碼 '0x450'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : 傳回
碼 '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : 傳回碼 '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : 傳回碼 '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : 傳回碼 '0x2'
Stop.

無言阿~~~
最後看他們的文章,他們是用這方法解決:
Use the ANGLE-library [code.google.com] to translate OpenGL calls into DirectX (default)
Use the native OpenGL driver for your graphics card
A copy of ANGLE is bundled in Qt 5. To use Option 1, you need to install the DirectX SDK

只好下載direct x sdk...安裝
再改
configure -prefix c:\qt511-static -release -static -platform win32-msvc2010 -c++11 -no-icu -qt-zlib -qt-libpng -qt-libjpeg -mp -nomake examples -nomake tests -skip qtwebkit -no-qml-debug

nmake
試試看吧~...結果....這次有撐過半小時沒stop....
等吧~成功了

接下來是
nmake install

也成功了~
接下來是設定qtcreater:


成功了~
這才是正確的qt 獨立執行檔 建置步驟.
this is correct build step for qt standalone application.






留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

舊有app在Android 12 閃退問題& app Splash screens

google play 正式發布前測試報告...非常好用.

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器