记录centos stream 9 编译qt5.15.10源码

参考qt官方提供的依赖列表 https://doc.qt.io/qt-5.15/linux-requirements.html
对于Linux,首先要安装下面列表的包,官网给出了ubuntu的包名称,centos安装就比较麻烦
首先就是名称不一样,再就是centos的包管理器无法提供安装,只能编译源码

Name Library Notes Configuration options Minimum working version
XRender libXrender X Rendering Extension; used for anti-aliasing
xcb-render libxcb-render X C Bindings for Render extension
xcb-render-util libxcb-render-util Utility library for XCB for Render
xcb-shape libxcb-shape X C Bindings for Shape extension
xcb-randr libxcb-randr X C Bindings for Resize and
xcb-xfixes libxcb-xfixes X C Bindings for Fixes Extension
xcb-sync libxcb-sync X C Bindings for Sync Extension
xcb-shm libxcb-shm X C Bindings for Shared Memory
xcb-icccm libxcb-icccm X C Bindings for ICCCM Protocol
xcb-keysyms libxcb-keysyms Utility library for XCB for keycode
xcb-image libxcb-image Utility library for XCB for XImage
xkbcommon libxkbcommon Keymap handling -xkbcommon or auto-detected 0.5.0
xkbcommon-x11 libxkbcommon-x11 Keymap handling auto-detected 0.5.0
Fontconfig libfontconfig Font customization and configuration -fontconfig or
FreeType libfreetype Font engine 2.3.0
Xext libXext X Extensions 6.4.3
X11 libX11 X11 client-side library 6.2.1
xcb libxcb X C Binding library 1.9
X11-xcb libX11-xcb Xlib/XCB interface library 1.3.2
SM libSM X Session Management -sm or auto-detected
ICE libICE Inter-Client Exchange -sm or auto-detected 6.3.5
glib libglib-2.0 Common event loop handling -glib or
pthread libpthread Multithreading 2.3.5

xcb

上边表格开始的大部分都是xcb,编译源代码即可
官网 https://xcb.freedesktop.org/
在这里 https://xcb.freedesktop.org/dist/ 下载所有的安装包

libxcb-1.15.tar     
xcb-util-cursor-0.1.4.tar  
xcb-util-image-0.4.1.tar    
xcb-util-renderutil-0.3.10.tar
xcb-util-0.4.1.tar  
xcb-util-errors-1.0.1.tar  
xcb-util-keysyms-0.4.1.tar  
xcb-util-wm-0.4.2.tar

然后编译安装即可,参考我另一个文章 https://www.cnblogs.com/feipeng8848/p/17680708.html
注意要先安装xcb-proto再安装其他的,再就是配置pkg-config的搜索路径
这里说一下我编译源码安装的一个重要原则,就是安装到当前账户的路径下,不污染系统路径(也就是/lib /usr/lib 等等路径)
所以configure的时候我都会加上--prefix=$HOME/usr/***安装到$HOME/usr/***

其他依赖

开始装的一些依赖库没有记录 gcc之类的,都是通过dnf安装的
主要是make过程中出现的问题(qtwebengine)及其如何解决
编译的命令如下

./configure -prefix /home/kun/usr/Qt/5.15.10 -opensource -confirm-license
make -j16
make install

configure阶段失败一般都是缺少,都是dnf解决的

链接gn失败

log如下

FAILED: gn
/usr/bin/g++ -O3 -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-strip-all -Wl,--as-needed -static-libstdc++ -pthread -o gn -Wl,--start-group tools/gn/gn_main.o base.a gn_lib.a -Wl,--end-group -ldl
/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Project ERROR: GN build error!
make[2]: *** [Makefile:98: sub-gn-pro-make_first] Error 3
make[2]: Leaving directory '/home/kun/dev-home/qtwebengine-everywhere-src-5.15.10/src/buildtools'
make[1]: *** [Makefile:55: sub-buildtools-make_first] Error 2
make[1]: Leaving directory '/home/kun/dev-home/qtwebengine-everywhere-src-5.15.10/src'
make: *** [Makefile:49: sub-src-make_first] Error 2

重要的是cannot find -lstdc++
一开始一直搞不懂为什么链接不到libstdc++.so,因为系统中是存在的
后来仔细查看编译命令:

/usr/bin/g++ -O3 -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-strip-all -Wl,--as-needed -static-libstdc++ -pthread -o gn -Wl,--start-group tools/gn/gn_main.o base.a gn_lib.a -Wl,--end-group -ldl

这里用到的是-static-libstdc++,也就是静态链接,需要*.a文件,查了下果然系统没有这个文件
centos stream9的dnf包管理器中没有找到相关的包,手动下载安装的
去pkgs.org找到对行的rmp文件,通过sudo rpm -ivh libstdc++-static-11.4.1-2.1.el9.x86_64.rpm
安装之后这个问题解决

perl-English 找不到

Project MESSAGE: perl -w /home/kun/usr/Qt/5.15.10/bin/syncqt.pl -module QtWebEngineCore -version 5.15.10 -outdir /home/kun/dev-home/qtwebengine-everywhere-src-5.15.10 -builddir /home/kun/dev-home/qtwebengine-everywhere-src-5.15.10 /home/kun/dev-home/qtwebengine-everywhere-src-5.15.10
Can't locate English.pm in @INC (you may need to install the English module) (@INC contains: /usr/local/lib64/perl5/5.32 /usr/local/share/perl5/5.32 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /home/kun/usr/Qt/5.15.10/bin/syncqt.pl line 55.
BEGIN failed--compilation aborted at /home/kun/usr/Qt/5.15.10/bin/syncqt.pl line 55.
Project ERROR: Failed to run: perl -w /home/kun/usr/Qt/5.15.10/bin/syncqt.pl -module QtWebEngineCore -version 5.15.10 -outdir /home/kun/dev-home/qtwebengine-everywhere-src-5.15.10 -builddir /home/kun/dev-home/qtwebengine-everywhere-src-5.15.10 /home/kun/dev-home/qtwebengine-everywhere-src-5.15.10
make[2]: *** [Makefile:48: sub-core_headers-pro-make_first] Error 3
make[2]: Leaving directory '/home/kun/dev-home/qtwebengine-everywhere-src-5.15.10/src/core'
make[1]: *** [Makefile:80: sub-core-make_first] Error 2
make[1]: Leaving directory '/home/kun/dev-home/qtwebengine-everywhere-src-5.15.10/src'
make: *** [Makefile:49: sub-src-make_first] Error 2

解决办法sudo dnf install perl-English

找不到expat.h头文件

   21 | #include <expat.h>
      |          ^~~~~~~~~
compilation terminated.
[10/11103] CXX obj/skia/skia/GrTwoPointConicalGradientLayout.o

虽然显示编译到第十个文件以后才挂掉,实际这个错误是编译第一个文件就出现了,
因为开启多线程的原因才导致后续的这些log输出

posted @ 2023-09-02 21:48  feipeng8848  阅读(307)  评论(0编辑  收藏  举报