QT 静态编译 包含所有子模块 和 openssl
时间: 2023-07-07 10:28:49 浏览: 79
以下是使用QT源码进行静态编译的指令,其中包含所有子模块和依赖项,同时也包括了OpenSSL支持:
```
./configure -prefix /opt/qt-static -static -release -opensource -confirm-license -no-sql-sqlite -no-icu -no-opengl -no-gtkstyle -no-pch -no-dbus -openssl-linked -openssl /usr/local/openssl-1.1.1i -nomake examples -nomake tests
```
请注意,这些选项将禁用某些功能和模块,并且可以根据您的需求进行修改。在执行上述指令之前,您需要先安装所有必要的依赖项,例如libxcb、libx11等。完成编译后,您可以将生成的库文件和可执行文件复制到您的目标系统中,以便在没有QT运行时的情况下运行您的应用程序。同时,您还需要将OpenSSL库文件一起复制到目标系统中,并确保QT应用程序能够正确链接和使用它。
相关问题
QT 源码静态编译 指令 包含所有子模块 和依赖
以下是使用QT源码进行静态编译的指令,其中包含所有子模块和依赖项:
```
./configure -prefix /opt/qt-static -static -release -opensource -confirm-license -no-sql-sqlite -no-icu -no-opengl -no-gtkstyle -no-pch -no-dbus -no-openssl -no-feature-xml -no-feature-printpreview -no-feature-style-fusion -nomake examples -nomake tests -skip qtwebengine -skip qtscript -skip qtdocgallery -skip qt3d -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtquickcontrols -skip qtquickcontrols2 -skip qtremoteobjects -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebsockets -skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns
```
请注意,这些选项将禁用某些功能和模块,并且可以根据您的需求进行修改。在执行上述指令之前,您需要先安装所有必要的依赖项,例如libxcb、libx11等。完成编译后,您可以将生成的库文件和可执行文件复制到您的目标系统中,以便在没有QT运行时的情况下运行您的应用程序。
QT 静态编译 包含 openssl
要在QT静态编译中包含OpenSSL支持,您需要在重新配置QT源代码时添加“-openssl-linked”选项,并将OpenSSL库路径传递给“-openssl”选项。例如,以下是在Ubuntu上编译QT 5.15.2静态版本,同时包括OpenSSL的示例命令:
1. 下载OpenSSL
在 https://www.openssl.org/source/ 下载源码包,例如 openssl-1.1.1i.tar.gz
2. 解压并编译OpenSSL
解压 openssl-1.1.1i.tar.gz 至 /usr/local/src/
```
cd /usr/local/src/openssl-1.1.1i/
./config --prefix=/usr/local/openssl-1.1.1i --openssldir=/usr/local/openssl-1.1.1i
make -j8
make install
```
以上命令将编译并安装OpenSSL到 /usr/local/openssl-1.1.1i 目录下。
3. 重新配置QT源代码
在重新配置QT源代码时,您需要添加以下选项:
```
./configure -prefix /opt/qt-static-openssl -static -release -opensource -confirm-license -no-sql-sqlite -no-icu -no-opengl -no-gtkstyle -no-pch -no-dbus -openssl-linked -openssl /usr/local/openssl-1.1.1i -nomake examples -nomake tests
```
在上面的命令中,我们添加了“-openssl-linked”选项,以便将OpenSSL库静态链接到QT二进制文件中。我们还使用“-openssl”选项指定了OpenSSL库的路径。
4. 编译QT源代码
然后,您可以使用以下命令编译QT源代码:
```
make -j8
```
这将使用8个线程并行编译QT源代码。整个编译过程可能需要一些时间,具体时间取决于您的计算机性能和QT源代码的大小。
5. 测试QT静态版本是否包含OpenSSL
编译完成后,您可以使用以下命令来测试QT静态版本是否包含OpenSSL:
```
ldd /opt/qt-static-openssl/bin/qmake | grep ssl
```
如果输出中包含“libssl.so”,则表示QT静态版本已经包含了OpenSSL支持。