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

发布时间 2023-09-02 21:54:13作者: feipeng8848

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

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

链接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输出