問題描述
我目前正在用 Qt 編寫代碼.如何靜態編譯代碼?
I am currently writing code in Qt. How to compile the code statically?
從 Qt 文檔中我了解到以下步驟
From Qt document I came to know the following step
1) Visual Studio 2008 -> commandPrompt -> QtDir -> configure -static -> nmake
1) Visual Studio 2008 -> commandPrompt -> QtDir -> configure -static -> nmake
但是,它占用了 17 GB,最后它在完成之前退出,指出空間不夠".
But, it took 17 GB and at the end it exited before the completion stating that "the space is not enough".
是否有任何簡單的方法可以將 Qt 應用程序編譯為獨立程序?
Is there any simple way to compile the Qt application as a stand alone program?
推薦答案
您已經使用了唯一可能的方法:將源代碼編譯為靜態.
You have already used the only way possible: compiling the source as static.
一些對磁盤大小影響非常大的事情(這似乎是這里的問題),以及相應的配置參數:
Some things that have a very large impact on disk size (which seems to be the problem here), with corresponding configure arguments:
- 禁用調試:
-release
- 禁用不需要的模塊,尤其是 QtWebKit:
-no-webkit -no-script -no-scripttools -no-qt3support -nomake demos -nomake tools -nomake examples
- 禁用 LTCG 支持,這會產生巨大的靜態庫的副作用:
no-ltcg
這些應該有助于將構建大小保持在最低限度.
These should help keep the build size to a minimum.
這篇關于如何將 Qt 編譯為靜態的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!