问题描述
我使用QtCreator为Linux创建了一个应用程序。该应用程序使用两个外部库和。我想部署该应用程序,以便它依赖的所有库都与可执行文件一起部署。
I made an application for Linux using QtCreator. The application uses two external libraries, qextserialport and qwt. I want to deploy the app such that all libraries it depends on are deployed alongside the executable file.
为Windows制作应用程序时,我只是将.dll文件复制到app.exe文件夹,它可以工作。但是如何在Linux上执行此操作?
When I made an application for Windows I just copied the .dll files into the app.exe folder, and it works. But how do I do this on Linux?
推荐答案
在Linux中,您可以:
In Linux you can:
1)静态链接依赖项
或
2)打包依赖项Windows样式和设置环境变量LD_LIBRARY_PATH指向包含动态库的子目录
2) pack dependencies windows-style and set environment variable LD_LIBRARY_PATH pointing to the subdirectory containing the dynamic libraries
[更新]
read man ld
,如果您未默认编译静态版本的库,则可能必须编译这些库的静态版本()。
read man ld
, may be you will have to compile static versions of the libraries if they are not compiled by default (look at this tutorial if you can't tell the difference).
synthesizerpatel的好评论,如果该库使用autoconf(很多linux软件都使用autoconf),它具有--enable-shared和--enable-static之类的选项。
Great comment by synthesizerpatel, if the library uses autoconf (a lot of linux software do), it has options like --enable-shared and --enable-static.
这篇关于Windows和Linux中独立的Qt应用程序和依赖项打包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!