Qt5.3.1 靜態編譯的configure,qt5.3.1configure
今天終於自己靜態編譯過了QT5.3.1, 成功用在項目上了, 記錄下configure指令.
configure -confirm-license -opensource -platform win32-msvc2013 -mp -debug-and-release -static -prefix "E:\Qt\5.3.1-static-vs2013" -qt-sql-sqlite -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -qt-freetype -no-qml-debug -no-angle -nomake tests -nomake examples -skip qtwebkit
其中 -mp 是啟用多核編譯的開關
Qt creator 怎設定靜態編譯
Qt預設的編譯方式是動態編譯的,但是有時候你編寫的程式要發布出去,帶很多動態庫檔案是很繁瑣的,此時就需要靜態編譯你的程式,Qt要實現靜態編譯必須庫檔案也是靜態編譯的,可以用這個命令編譯靜態庫:1.將C:\Qt\2010.05\qt\mkspecs\win32-g++檔案中的QMAKE_LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc 改為QMAKE_LFLAGS = -static -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc2.在開始菜單裡找到Qt Command Prompt並運行,輸入命令: configure -static -debug-and-release -no-exceptions -L "C:\Qt\2010.05\qt\include" -L "C:\Qt\2010.05\qt\lib"-L指定一下路徑,防止用到vc的標頭檔選擇開源:O;選擇license:y;3.上一條命令運行成功後再輸入命令: mingw32-make sub-src等1 ~3 小時可能就運行完了 完成後就ok了。。。
用configureexe 把 QT 編譯成靜態庫後 就不可以產生 DLL了,只可以產生 a,是為何?
重新改配置為shared。你既要靜態又要動態,不矛盾嗎,怎麼可能相容和工作。