如何静态构建Qt 5 [英] How to build Qt 5 statically

查看:906
本文介绍了如何静态构建Qt 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在基于Qt 5.0.1的Qt Creator 2.6.2在linux环境中工作。该应用程序在我进行编译的计算机上正常工作,但当我在另一台计算机上执行它时会出现错误:

I worked with Qt Creator 2.6.2 based on Qt 5.0.1 in a linux environnement. The application works fine on the computer where I made the compilation but when I execute it on another computer I got errors like :

error while loading shared libraries: libQt5WebKitWidgets.so.5: cannot open shared object file: No such file or directory
error while loading shared libraries: libxslt.so.1: cannot open shared object file: No such file or directory

我在此找到了一些解决方案链接(一些链接已经死了)。

I found some solutions in this link (some links are dead).

所以我添加到我的。

CONFIG += static

要静态编译我的项目。

我认为我会得到的文件会更大,但我有相同的大小和相同的错误。

I thought the file I'll get will be larger but I got the same size and the same errors.

谢谢。

推荐答案

Qt共享库存在于您测试它的其他计算机上。因此,您需要:

The Qt shared libraries don't exist on the other computer you tested it on. So you need to either:


  1. 将共享库复制到其他计算机。或...

  2. 创建一个静态Qt版本以与您的应用程序链接。

不足以将 CONFIG + = static 添加到.pro文件中,您还需要Qt静态库。所以做#2你需要得到Qt源代码并自己构建它。

It's not sufficient to just add CONFIG += static to your .pro file, you also need Qt static libraries. So to do #2 you'll need to get the Qt source code and build it yourself.

此外,Qt是根据LGPL许可的,所以你需要在静态链接时注意到。有些人认为LGPL不允许静态链接(除非你LGPL自己的代码)和其他人相信它(只要你愿意释放你的应用程序的目标代码)。但这是一个完整的其他讨论。

Also, Qt is licensed under the LGPL so you'll need to be aware of that when static linking. There are some who believe that the LGPL does not allow static linking (unless you LGPL your own code) and others who believe that it does (so long as you're willing to release the object code for your app). But that's a whole other discussion.

这篇关于如何静态构建Qt 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆