How to deploy QT5.2 application?

流过昼夜 提交于 2020-01-06 17:55:07

问题


I have QT 5.2 installed on Ubuntu 12.04. I did not build it, but simply downloaded and unzipped from the QT website. My question is how can we package the required libs along with the executable for deployment? The QT documentation says that we should build QT for static linking, but the "configure" file is missing in the QT directory. Thanks in advance.


回答1:


Ok. So I finally managed to deploy my Qt app along with its dependencies after countless hours of googling. This was done on Ubuntu 12.04 with Qt 5.2.

This is how I did it:

  1. Statically build Qt from the source using the following command :

    ./configure -opensource -confirm-license -prefix ./qtbase -make libs -make tools -release -opengl desktop -static -skip qtwebkit -no-icu -nomake tests -nomake examples
    
    make -j -4
    

You can download the source from http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.tar.gz You cannot static build the installer version of Qt.

  1. Open your Qt project and rebuild it. The Qt dependencies will be built into the app executable. Check with ldd to see if it was done correctly.

    ldd  ./<app_executable>
    
  2. Now when you try to run this on a system without Qt it might ask for other third party dependencies which you see with ldd. Eg: libxcb-... You could either install these dependencies with apt-get on the target system or supply the libs with your app. That is: put the required .so files and their soft links into a directory named libs along with your executable.

  3. After the lib dependency problems are fixed the App will give an error about missing Qt fonts. Easiest way to fix this is to supply the Qt fonts folder along with the app.

  4. This link gives a good way of doing this: http://goblincoding.com/2013/11/07/deploying-qt-5-applications-on-ubuntu-12-04/

  5. The summary of the above page is that you need to supply a small bash script to run your app. the script should be as follows:

    #~/bin/bash
    export LD_LIBRARY_PATH=./libs
    export QT_QPA_FONTDIR=./fonts
    ./<app_executable>
    

The target system will now find the libs and the fonts from the directories you supplied and will run without issues. Hope this helped.

NOTE: I haven't tried, but this script method should work even if you are supplying the Qt libs as well without statically building the qt source.



来源:https://stackoverflow.com/questions/21626771/how-to-deploy-qt5-2-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!