久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何讓 Qt 和 Qtcreator 靜態鏈接庫而不是動態鏈接

How to make Qt and Qtcreator link the libraries statically instead of dynamic?(如何讓 Qt 和 Qtcreator 靜態鏈接庫而不是動態鏈接?)
本文介紹了如何讓 Qt 和 Qtcreator 靜態鏈接庫而不是動態鏈接?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我知道這可能是一個與許多其他問題類似的問題,但在搜索了很多次但未能得到明確有效的解決方案后,我不得不提出這個問題.

I know it might be a question similar to many others, but after searching for many times and failing to get a definitive and effective solution I'm having to ask this question.

我正在使用 Qt 5.2.0 for Windows 32-bit (VS 2010, 570 MB),我已經完成了我的編程,一切都完成了.但現在我想將它作為 .exe 文件分發給我的同事,但這樣做不會很復雜,也為了避免分發 dll 文件,我需要使用靜態鏈接構建程序.

I'm using Qt 5.2.0 for Windows 32-bit (VS 2010, 570 MB), and I have already made my programming, and it's all done. But now I want to distribute it as .exe file to my colleagues, but to do so without complication and to avoid having to distribute dll files I need to build the program using static linking.

能否請您描述一下我如何制作 Qt 5.2.0 for Windows 32 位(VS 2010,570 MB) 使用靜態鏈接構建整個程序?

Could you please describe how I can make Qt 5.2.0 for Windows 32-bit (VS 2010, 570 MB) build the whole program using static linking?

謝謝.

推薦答案

你可以在 qmake 中使用 CONFIG 變量:

You can use the CONFIG variable for this with qmake:

CONFIG += static

CONFIG += staticlib

但是,您需要確保您擁有所有要捆綁的庫,以靜態方式提供.

However, you will need to make sure that you have all the libraries that you wish to bundle up, available as static.

如果您遵守許可,這也包括 Qt 框架本身.官方安裝只設置動態庫(.dll文件),所以需要自己構建Qt來完成.

This includes the Qt framework itself as well if you comply with the license to do so. The official installation only sets up dynamic libraries (.dll files), so you would need to build Qt on your own to accomplish this.

您可以使用以下命令為您自己的目的靜態構建 Qt:

You could use the following commands to build Qt statically for your own purpose:

configure -developer-build -opensource -nomake examples -nomake tests -static
qmake -r
nmake

請注意,通常在構建像您這樣的第三方 Qt 軟件時,最好使用以下參數調用 qmake 以正確傳遞您的環境:

Note that in general when building third-party Qt softwares like yours, you better invoke qmake with the following parameter to pass your environment properly:

qmake -r -spec win32-msvc2010 

還請注意,正如 Frank 和 ManuelH 在評論中所寫的那樣,如果您的應用程序未獲得 LGPL 的免費許可或至少與 LGPL 兼容,并且您也未使用 Qt 的商業許可,則不允許靜態鏈接.最好在采取您的方法之前確定這一點.

Please also noted that as Frank and ManuelH wrote in the comment, static linkage is not allowed if your application is not free licensed either a LGPL or at least compatible to LGPL, nor do you use commercial license for Qt. It is better to make sure about this before picking up your approach.

完成后,您可以以常規方式使用 LIBS 變量,例如:將靜態庫的路徑與庫名稱一起傳遞給它,如下所示:

Once that is done, you can use the LIBS variable in the regular way, as in: pass the path of your static library to it along with the library name, so something like this:

LIBS += -L/path/to/the/static/library -lstaticlibraryname

請注意,傳遞給 -l 參數的靜態庫名稱不應包含靜態庫擴展名,例如 Windows 上的 .lib.

Note that the static library name passed to the -l parameter should not contain the static library extension, for instance .lib on Windows.

作為后備,您始終可以靜態鏈接其他庫,并將 Qt dll 文件放在可執行文件旁邊,然后將該文件夾部署為包".這對您來說可能是更簡單的方法.

As a fallback, you can always link other libraries statically, and put the Qt dll files beside the executable, and you deploy the folder as a "package". That is probably the easier way for you to go.

這篇關于如何讓 Qt 和 Qtcreator 靜態鏈接庫而不是動態鏈接?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 国产精品久久久精品 | 国产婷婷精品 | 欧美视频一区 | 国产在线视频一区 | 婷婷久久综合 | 日韩中文一区二区三区 | 天天干人人 | 久久视频精品 | 一区网站 | 四虎在线观看 | 日本三级黄视频 | 蜜桃av鲁一鲁一鲁一鲁 | 一区二区三区精品视频 | 久久久国产一区二区三区四区小说 | 中文字幕av在线播放 | 国产美女福利在线观看 | 国产视频久久久 | 午夜成人在线视频 | 色香婷婷| 午夜寂寞福利视频 | 欧美一级二级视频 | 国产精品久久久久久久久久软件 | 久久久一区二区三区四区 | 天堂一区二区三区 | 红桃视频一区二区三区免费 | 一区二区三区四区不卡视频 | 成人欧美一区二区三区黑人孕妇 | 亚洲精品国产精品国自产在线 | 国产欧美日韩一区二区三区在线观看 | 国产精品免费大片 | 欧美日韩久久久 | 国产高清毛片 | 天天夜夜操 | 精品伊人 | 日韩一区二区在线播放 | 色婷婷精品久久二区二区蜜臂av | 久视频在线观看 | 免费在线观看91 | 精品一区二区三区不卡 | 久久精品视频一区二区三区 | www.久久久 |