久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Ubuntu下如何使用linuxdeployqt打包Qt程序

174次閱讀
沒有評論

共計 2207 個字符,預計需要花費 6 分鐘才能閱讀完成。

本篇內容介紹了“Ubuntu 下如何使用 linuxdeployqt 打包 Qt 程序”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓丸趣 TV 小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

1. 配置 qt 環境

首先,我們先把 qt 環境配置好,在~/.bashrc 中加入:

export path=/home/xl/qt5.9.2/5.9.2/gcc_64/bin:$path
export ld_library_path=/home/xl/qt5.9.2/5.9.2/gcc_64/lib:$ld_library_path
export qt_plugin_path=/home/xl/qt5.9.2/5.9.2/gcc_64/plugins:$qt_plugin_path
export qml2_import_path=/home/xl/qt5.9.2/5.9.2/gcc_64/qml:$qml2_import_path

其中 /home/xl/qt5.9.2/5.9.2/ 目錄要根據自己電腦上安裝的 qt 路徑進行修改。

然后執行 sourec ~/.bashrc 使配置生效。

2. 編譯 linuxdeployqt

雖然有放出編譯好的包,但是由于我使用的是 ubuntu18,系統版本過高,因此還是選擇編譯代碼的方式。

為了避免編譯好的包運行時檢測到我們的系統版本過高,不繼續執行的問題,我們編譯前,將 tools/linuxdeployqt/main.cpp 中的下述代碼注釋掉:

// opensuse leap 15.0 uses glibc 2.26 and is used on obs
 /*if (strverscmp (glcv,  2.27)  = 0) { // 注釋版本檢查
 qinfo()    error: the host system is too new. 
 qinfo()    please run on a system with a glibc version no newer than what comes with the oldest 
 qinfo()    currently still-supported mainstream distribution (xenial), which is glibc 2.23. 
 qinfo()    this is so that the resulting bundle will work on most still-supported linux distributions. 
 qinfo()    for more information, please see 
 qinfo()    https://github.com/probonopd/linuxdeployqt/issues/340 
 return 1;
 }*/

然后就可以使用 cmake 和 make 進行編譯。生成好的可執行程序是 tools/linuxdeployqt/linuxdeployqt。

最后為了方便使用,可以將生成的可執行程序拷貝到系統的 /usr/local/bin/ 目錄。

3. 打包

將 qt 編譯的好的程序拷貝到一個單獨的文件夾中。

  然后執行 linuxdeployqt appname.

一般情況下會很順利的完成,當前目錄下會有個 apprun,直接執行它就可以。

  但是有時候并不是那么順利,應該是系統中還缺少相應的庫。比如,我遇到的錯誤是:

error: could not start patchelf.
error: make sure it is installed on your $path.
error: error reading rpath with patchelf  libqt5widgets.so  :  
error: error reading rpath with patchelf  libqt5widgets.so  : 

這個錯誤是表明缺少需要的 pathchelf 工具,直接安裝即可解決:

sudo apt install patchelf

然后又出現了下面這個錯誤:

error: ldd outputline: libjasper.so.1 = not found
error: for binary: /home/xl/qt5.9.2/5.9.2/gcc_64/plugins/imageformats/libqjp2.so
error: please ensure that all libraries can be found by ldd. aborting.

這表明我們系統中是缺少了 libqjp2.so 這個庫的。其實很奇怪,本地明明是已經可以跑起來了,為什么還缺少這個庫文件。但是解決方法很簡單,缺什么就裝什么:

sudo add-apt-repository  deb http://security.ubuntu.com/ubuntu xenial-security main 
sudo apt update
sudo apt install libjasper1 libjasper-dev

安裝完成之后,就順利打包了。

“Ubuntu 下如何使用 linuxdeployqt 打包 Qt 程序”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注丸趣 TV 網站,丸趣 TV 小編將為大家輸出更多高質量的實用文章!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-14發表,共計2207字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 西平县| 九龙坡区| 藁城市| 成安县| 商水县| 板桥市| 刚察县| 墨脱县| 聂荣县| 通辽市| 区。| 广河县| 武穴市| 城市| 张家界市| 西城区| 双桥区| 凤山市| 南阳市| 昌黎县| 蒙城县| 博兴县| 郴州市| 酒泉市| 通化县| 平阴县| 济南市| 隆回县| 六枝特区| 平乡县| 中西区| 错那县| 札达县| 濮阳县| 烟台市| 剑川县| 永兴县| 临夏市| 光泽县| 亚东县| 靖宇县|