Qt源码编译

记录一下centos 7.9 编译 qt5.15.2过程

参考过程

下载源码:https://download.qt.io/archive/qt/5.15/5.15.2/single/

tar -Jxvf qt-everywhere-src-5.15.2.tar.xz
mkdir build
cd build

安装依赖:

yum groupinstall "Development Tools"
yum install mesa-libGL-devel libpng-devel libjpeg-turbo-devel freetype-devel
yum install libxcb libxcb-devel xcb-util xcb-util-devel mesa-libGL-devel libxkbcommon-devel
yum install libxcb-devel libx11-xcb-devel libXrender-devel libxi-devel libxkbcommon-devel libxkbcommon-x11-devel
 
yum install xcb*
yum install libxcb*
yum install libxcb-*
yum install x11*
yum install libx11*
yum install libx11-*
yum install libxkbcommon-dev
yum install libxkbcommon-x11-dev
yum install nss*
yum install libdbus*
yum install nodejs
yum install libclang*
yum install llvm*
yum install gperf
0x02:

配置选项说明:


../configure -prefix /opt/Qt5152 \
   -opensource \
   -release \
   -force-debug-info \
   -separate-debug-info \
   -developer-build \
   -shared \
   -c++std c++17 \
   -xcb \
   -xcb-xlib \
  -gui -widgets \
   -bundled-xcb-xinput \
   -make libs \
   -nomake tests \
   -nomake examples \
   -skip qtmacextras \
   -skip qtandroidextras \
   -skip qtwebengine

make -j 8
make install

单独编译某个模块

  1. 在源码要目录 : ./configure 命令生成 Makefile 文件
  2. 执行 make module-<module_name>,例如: make module-qtwebkit
  3. make install

如果需要开启openssl,需要进行如下配置

 ./configure -prefix /opt/Qt5152 -openssl-linked     -opensource     -developer-build     -shared     -c++std c++17     -xcb     -xcb-xlib     -gui -widgets     -bundled-xcb-xinput     -make libs     -nomake tests     -nomake examples     -skip qtmacextras     -skip qtandroidextras     -skip qtwebengine

如果报错

Note: Also available for Linux: linux-clang linux-icc

WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.

Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation.
On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution.
On macOS, you can use Homebrew's llvm package.
On Windows, you must set LLVM_INSTALL_DIR to the installation path.

ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl' failed.

解法

wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz
tar -xzf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w

# 编译安装(自定义路径)
./config --prefix=/opt/openssl-1.1.1 --openssldir=/opt/openssl-1.1.1 shared zlib
make -j$(nproc)
sudo make install

./configure -prefix /opt/Qt5152 \
    -openssl-linked OPENSSL_INCDIR=/opt/openssl-1.1.1/include OPENSSL_LIBDIR=/opt/openssl-1.1.1/lib\
    -opensource -confirm-license \
    -developer-build \
    -shared -with-tools \
    -c++std c++17 \
    -xcb \
    -xcb-xlib \
    -gui -widgets \
    -bundled-xcb-xinput \
    -make libs \
    -nomake tests \
    -nomake examples \
    -skip qtmacextras \
    -skip qtandroidextras \
    -skip qtwebengine


然后
gmake -j $(nproc)
gmake install
../src/smtpclient.cpp: In member function ‘void SmtpClient::setConnectionType(SmtpClient::ConnectionType)’:
../src/smtpclient.cpp:97:22: error: expected type-specifier before ‘QSslSocket’
         socket = new QSslSocket(this);
error: 'QSslSocket'

测试是否支持ssl

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容