厦门外贸网站建设 之家,电视购物平台,做胃肠科网站,适合工作室做的项目背景
需要在龙芯#xff08;Loongson#xff09;CPU#xff0c;UOS 系统下#xff0c;进行国产化项目适配#xff0c;UOS 自带 Qt 5.11#xff0c;但是版本过老#xff0c;与目前基于 Qt 5.15.2 项目存在不兼容情况#xff0c;故需要自行编译 Qt 5.15.2开发环境。
软…背景
需要在龙芯LoongsonCPUUOS 系统下进行国产化项目适配UOS 自带 Qt 5.11但是版本过老与目前基于 Qt 5.15.2 项目存在不兼容情况故需要自行编译 Qt 5.15.2开发环境。
软硬件信息
处理器Loongson-3A5000 (四核 / 四逻辑处理器)主板Loongson-LS 3A5000-7A 1000-1w-V0.1-CRB架构loongarch 64家族Loongson-64 bit系统UOS V20 1060内核 4.19.0-loongson-3-desktop
下载 Qt 源码
这里使用国内的镜像地址下载源码
Qt 5.15.2 http://mirrors.ustc.edu.cn/qtproject/archive/qt/5.15/5.15.2/single/
由于龙芯 3A5000 CPU 采用了全新的 LoongArch 架构所以直接编译 Qt 源码通常会有问题尤其是 QWebEngine 不支持 LoongArch 架构。不过可能高版本会好些我编译 5.15.9 版本一次编译通过而 5.15.2 编译的时候就 Segmentation fault。
所以需要向龙芯那边的人要来针对 LoongArch 适配的 Qt 源码包通常是有 patch 的源码包。然后使用提供的这个源码包进行编译即可不过截止此文发表时间 2023-11-12龙芯那边只有 Qt 5.15.2 的包如果是其他版本可能需要自行打 patch 适配了。
打 patch
以 QWebEngine 为例演示如何打 patch
$ ls
qtwebengine-opensource-src_5.15.2dfsg-lnd.3.debian.tar.xz qtwebengine-opensource-src_5.15.2dfsg-lnd.3.dsc qtwebengine-opensource-src_5.15.2dfsg.orig.tar.xz将这三个包放在同一目录下含有 debian 字样的文件就是 patch 包。
然后使用命令自动解压并打 patch
$ dpkg-source -x *.dsc
dpkg-source: warning: extracting unsigned source package (qtwebengine-opensource-src_5.15.2dfsg-lnd.3.dsc)
dpkg-source: info: extracting qtwebengine-opensource-src in qtwebengine-opensource-src-5.15.2dfsg
dpkg-source: info: unpacking qtwebengine-opensource-src_5.15.2dfsg.orig.tar.xz
dpkg-source: info: unpacking qtwebengine-opensource-src_5.15.2dfsg-lnd.3.debian.tar.xz
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: applying run-unbundling-script.patch
dpkg-source: info: applying system-lcms2.patch
dpkg-source: info: applying system-nspr-prtime.patch
dpkg-source: info: applying system-icu-utf.patch
dpkg-source: info: applying verbose-gn-bootstrap.patch
dpkg-source: info: applying mipsel-linux-5.patch
dpkg-source: info: applying mipsel-ptrace-include.patch
dpkg-source: info: applying mipsel-no-dav1d.patch
dpkg-source: info: applying mipsel-link-atomic.patch
dpkg-source: info: applying sandbox-time64-syscalls.patch
dpkg-source: info: applying mipsel-code-range-size.patch
dpkg-source: info: applying 0001-port-chromium_qt-to-loongarch64.patch
dpkg-source: info: applying 0002-fix-third_party-for-loongarch64.patch
dpkg-source: info: applying 0003-port-breakpad-for-loongarch64.patch
dpkg-source: info: applying 0004-port-ffmpeg-to-loongarch64-for-chromium.patch
dpkg-source: info: applying 0005-port-ffmpeg-to-loongarch64-for-chromium-add-la64-rel.patch
dpkg-source: info: applying 0006-fix-third_party-for-loongarch64-add-files-for-la64.patch
dpkg-source: info: applying 0007-port-icu-for-loongarch64.patch
dpkg-source: info: applying 0008-port-lss-for-loongarch64.patch
dpkg-source: info: applying 0009-port-pdfium-for-loongarch64.patch
dpkg-source: info: applying 0010-port-swiftshader-for-loongarch64.patch
dpkg-source: info: applying 0011-port-webrtc-for-loongarch64.patch
dpkg-source: info: applying 0012-port-v8-for-loongarch64.patch
dpkg-source: info: applying 0013-make-qtwebengine-can-be-compiled-for-loongarch64.patch
dpkg-source: info: applying 0014-fix-compile-errors-for-mips64el.patch
dpkg-source: info: applying 0015-fix-compiler-internal-error-for-loongarch64.patch
dpkg-source: info: applying 0016-fix-compile-error-for-loongarch64.patch可以看到patch 已经自动打好了并在 qtwebengine-opensource-src-5.15.2dfsg 目录下
$ ls
qtwebengine-opensource-src-5.15.2dfsg qtwebengine-opensource-src_5.15.2dfsg-lnd.3.debian.tar.xz qtwebengine-opensource-src_5.15.2dfsg-lnd.3.dsc qtwebengine-opensource-src_5.15.2dfsg.orig.tar.xz但是龙芯提供的源码包有文件缺失的情况这个后面编译时会遇到对应的错误。
环境配置
安装 Qt 所需的依赖
sudo apt install build-essential libgl1-mesa-dev libxkbcommon-dev libnss3-dev libdbus-1-dev gperf flex bison安装 xcb 相关
sudo apt-get install ^libxcb.*-dev libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev这一步比较关键因为涉及到编译之后有 libqxcb.so如果缺失会导致错误。
如果需要使用到 QWebEngine 模块那么需要安装以下依赖库
sudo apt install libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libxtst-dev libxss-dev libdbus-1-dev libevent-dev libfontconfig1-dev libcap-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libegl1-mesa-dev gperf bison nodejs编译 Qt
进入解压后的 qt-everywhere-src-5.15.2 目录开始配置
./configure -prefix /home/leo/Qt -opensource -confirm-license -nomake examples -release-prefix /home/leo/Qt: 指定 Qt 的安装路径-opensource: 指定使用开源版本-nomake examples: 不编译 examples-release: release 模式
这个步骤会检查相关的库是否存在若不存在则将缺少的安装。 安装完缺失的依赖库后记得先删除 config.cache 缓存文件。
或者使用脚本运行创建 run.sh 脚本
#! /bin/bash
./configure -prefix /home/leo/Qt/5 \
-opensource -confirm-license \
-nomake examples \
-nomake tests \
-release \
-skip qt3d \
-skip qtcharts \
-skip qtandroidextras \
-skip qtlocation \
-skip qtmultimedia \
-skip qtsensors \
-skip qtserialbus \
-skip qtserialport \
-skip qtwayland可以指定跳过编译哪些模块以加快编译速度如果你不需要 QWebEngine那么推荐跳过编译这样能大幅加快编译速度同时能避免因 QWebEngine 导致的编译错误。
开始编译
make在编译过程中可能会遇到一些依赖问题需要根据实际情况进行解决。
编译完成后即可安装
make install编译 QWebEngine可选
编译 QWebEngine 这一步是因为需要开启音视频功能支持 H264 编码格式等。
配置编译好的 Qt 环境到 .bashrc之后创建 build 文件夹执行命令
qmake ../qtwebengine.pro -- -webengine-proprietary-codecsmake输出信息
g -Wl,--no-undefined -Wl,--version-script,QtPdfWidgets.version -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath-link,/home/geit/Qt/5.15.2/lib -shared -Wl,-soname,libQt5PdfWidgets.so.5 -o libQt5PdfWidgets.so.5.15.2 .obj/qpdfview.o /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/lib/libQt5Pdf.so /home/geit/Qt/5.15.2/lib/libQt5Widgets.so /home/geit/Qt/5.15.2/lib/libQt5Gui.so /home/geit/Qt/5.15.2/lib/libQt5Core.so -lpthread -lGL
ln -s libQt5PdfWidgets.so.5.15.2 libQt5PdfWidgets.so
ln -s libQt5PdfWidgets.so.5.15.2 libQt5PdfWidgets.so.5
ln -s libQt5PdfWidgets.so.5.15.2 libQt5PdfWidgets.so.5.15
rm -f ../../lib/libQt5PdfWidgets.so.5.15.2
mv -f libQt5PdfWidgets.so.5.15.2 ../../lib/libQt5PdfWidgets.so.5.15.2
rm -f ../../lib/libQt5PdfWidgets.so
rm -f ../../lib/libQt5PdfWidgets.so.5
rm -f ../../lib/libQt5PdfWidgets.so.5.15
mv -f libQt5PdfWidgets.so ../../lib/libQt5PdfWidgets.so
mv -f libQt5PdfWidgets.so.5 ../../lib/libQt5PdfWidgets.so.5
mv -f libQt5PdfWidgets.so.5.15 ../../lib/libQt5PdfWidgets.so.5.15
make[2]: 离开目录“/home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/pdfwidgets”
make[1]: 离开目录“/home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src”编译完之后就可以安装到 Qt 的路径下
$ make installgeitgeit:~/Documents/qtwebengine-opensource-src-5.15.2dfsg/build$ make install
cd src/ ( test -e Makefile || /home/geit/Qt/5.15.2/bin/qmake -o Makefile /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/src.pro ) make -f Makefile install
make[1]: 进入目录“/home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src”....make[2]: 进入目录“/home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/core”
( test -e Makefile.core_headers || /home/geit/Qt/5.15.2/bin/qmake -o Makefile.core_headers /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/core/core_headers.pro ) make -f Makefile.core_headers install
make[3]: 进入目录“/home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/core”
sed -e s,/home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/lib,$$[QT_INSTALL_LIBS],g -e s,/home/geit/Qt/5.15.2/lib,$$[QT_INSTALL_LIBS],g ../../lib/libQt5WebEngineCore.prl /home/geit/Qt/5.15.2/lib/libQt5WebEngineCore.prl
sed -e s,/home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/lib,/home/geit/Qt/5.15.2/lib,g ../../lib/Qt5WebEngineCore.la /home/geit/Qt/5.15.2/lib/Qt5WebEngineCore.la
/home/geit/Qt/5.15.2/bin/qmake -install qinstall /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/include/QtWebEngineCore/QWebEngineCallback /home/geit/Qt/5.15.2/include/QtWebEngineCore/QWebEngineCallback错误解决
如果没看到错误可以使用 make -j1 单进程编译然后错误信息就能看到了。
找不到 sqlite3.h 头文件
/home/geit/Documents/qt-everywhere-src-5.15.2/qtbase/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp:66:10: fatal error: sqlite3.h: 没有那个文件或目录
#include sqlite3.h这个问题就是因为龙芯提供的 qtbase 源码包有 debian rules 文件rules 里做了一些修改指定使用系统的 sqlite。可以将 qt-everywhere-src-5.15.2 里的 qtbase 拷贝到目前的编译目录最好使用文件管理器进行因为可以选择合并跳过替换这样就相当于只把缺失的文件给拷贝过来了。
error: cast from ‘QTJSC::JSCell*’ to ‘int32_t’ {aka ‘int’} loses precision
/home/geit/Documents/qt-everywhere-src-5.15.2/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h: In constructor ‘QTJSC::JSValue::JSValue(QTJSC::JSCell*)’:
/home/geit/Documents/qt-everywhere-src-5.15.2/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h:493:57: error: cast from ‘QTJSC::JSCell*’ to ‘int32_t’ {aka ‘int’} loses precision [-fpermissive]u.asBits.payload reinterpret_castint32_t(ptr);^
/home/geit/Documents/qt-everywhere-src-5.15.2/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h: In constructor ‘QTJSC::JSValue::JSValue(const QTJSC::JSCell*)’:
/home/geit/Documents/qt-everywhere-src-5.15.2/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h:505:78: error: cast from ‘QTJSC::JSCell*’ to ‘int32_t’ {aka ‘int’} loses precision [-fpermissive]u.asBits.payload reinterpret_castint32_t(const_castJSCell*(ptr));^
make[3]: *** [Makefile:3960obj/release/JSBase.o] 错误 1原因已经告诉你了‘QTJSC::JSCell*’ 转’int 32_t’会丢失精度。 那么我们打开这个文件对应行进行修改即可。
qt-everywhere-src-5.15.2/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h 跳转到 493 行和 505 行把 int_32_t 改成 int 64_t 即可
u.asBits.payloadreinterpret_castint32_t(ptr); - u.asBits.payloadreinterpret_castint64_t(ptr);
u.asBits.payloadreinterpret_castint_32_t(const_castJSCell*(ptr)); - u.asBits.payloadreinterpret_castint64_t(const_castJSCell*(ptr));ninja: Entering directory /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/core/release
ninja: error: ../../../../src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/lighthouse-dt-bundle. js, needed by resources/inspector/root. js, missing and no known rule to make it
make[3]: *** [Makefile. gn_run:460run_ninja] 错误 1遇到这个错误是因为debain rules 把这些文件删除了可以从qt-everywhere-src-5.15.2/qtwebengine/src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/路径下将缺失的文件拷贝过去即可 ninja: Entering directory /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/core/release
ninja: error: ../../../../src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/report-assets/report-generator. js, needed by resources/inspector/root. js, missing and no known rule to make it
make[3]: *** [Makefile. gn_run:460run_ninja] 错误 1问题同上解决方案也是一致拷贝缺失的文件 /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/3 rdparty/ninja/ninja -v -C /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/core/release QtWebEngineCore
ninja: Entering directory /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/build/src/core/release
ninja: error: ../../../../src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/diff/diff_match_patch. js, needed by resources/inspector/root. js, missing and no known rule to make it
make[3]: *** [Makefile. gn_run:460run_ninja] 错误 1问题同上解决方案也是一致拷贝缺失的文件
简便方法可以直接将qt-everywhere-src-5.15.2/qtwebengine/src/3 rdparty/chromium/third_party/devtools-frontend/src路径下的文件全都拷贝过去 structure compressgzip file../../../third_party/web-animations-js/sources/web-animations-next-lite.min.js nameIDR_POLYMER_1_0_WEB_ANIMATIONS_JS_WEB_ANIMATIONS_NEXT_LITE_MIN_JS typechrome_html /: [Errno 2] No such file or directory: /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/third_party/web-animations-js/sources/web-animations-next-lite. min. js
Traceback (most recent call last):File ../../../../src/3 rdparty/chromium/tools/grit/grit. py, line 29, in modulesys.exit (grit. grit_runner.Main (sys. argv[1:]))File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/grit_runner. py, line 314, in Mainreturn toolobject.Run (options, args[1:])File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/tool/build. py, line 266, in Runself.res.RunGatherers ()File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/node/misc. py, line 665, in RunGatherersnode.RunPreSubstitutionGatherer (debugdebug)File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/node/structure. py, line 240, in RunPreSubstitutionGathererself.gatherer.Parse ()File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/gather/chrome_html. py, line 374, in Parseutil.ReadFile (filename, utf-8),File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/util. py, line 216, in ReadFilewith io.open (abs (filename), mode, encodingencoding) as f:
IOError: [Errno 2] No such file or directory: /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/third_party/web-animations-js/sources/web-animations-next-lite. min. js很明显web-animations-js 库文件缺失。 structure compressgzip file../../../third_party/polymer/v3_0/components-chromium/polymer/polymer_bundled.min.js nameIDR_POLYMER_3_0_POLYMER_POLYMER_BUNDLED_MIN_JS typechrome_html /: [Errno 2] No such file or directory: /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/third_party/polymer/v 3_0/components-chromium/polymer/polymer_bundled. min. js
Traceback (most recent call last):File ../../../../src/3 rdparty/chromium/tools/grit/grit. py, line 29, in modulesys.exit (grit. grit_runner.Main (sys. argv[1:]))File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/grit_runner. py, line 314, in Mainreturn toolobject.Run (options, args[1:])File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/tool/build. py, line 266, in Runself.res.RunGatherers ()File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/node/misc. py, line 665, in RunGatherersnode.RunPreSubstitutionGatherer (debugdebug)File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/node/structure. py, line 240, in RunPreSubstitutionGathererself.gatherer.Parse ()File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/gather/chrome_html. py, line 374, in Parseutil.ReadFile (filename, utf-8),File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/util. py, line 216, in ReadFilewith io.open (abs (filename), mode, encodingencoding) as f:
IOError: [Errno 2] No such file or directory: /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/third_party/polymer/v 3_0/components-chromium/polymer/polymer_bundled. min. js这次是 polymer 缺失文件 FAILED: gen/ui/resources/webui_resources_grd_grit. d. stamp gen/ui/resources/grit/webui_resources. h gen/ui/resources/grit/webui_resources_map. cc gen/ui/resources/grit/webui_resources_map. h gen/ui/resources/webui_resources. pak gen/ui/resources/webui_resources. pak. info
/usr/bin/python 2 ../../../../src/3 rdparty/chromium/tools/grit/grit. py -i ../../../../src/3 rdparty/chromium/ui/webui/resources/webui_resources. grd build -o gen/ui/resources --depdir . --depfile gen/ui/resources/webui_resources_grd_grit. d --write-only-new1 --depend-on-stamp -D scale_factors2 x -D _chromium -E CHROMIUM_BUILDchromium -D desktop_linux -D use_aura -D use_nss_certs -D use_ozone -t linux 2 -D optimize_webuifalse -E root_gen_dirgen -f gen/tools/gritsettings/default_resource_ids --assert-file-list obj/ui/resources/webui_resources_grd_expected_outputs. txt
Error processing node ?xml version1.0 encodingUTF-8?
include compressgzip filejs/jstemplate_compiled.js flattenhtmltrue nameIDR_WEBUI_JSTEMPLATE_JS typeBINDATA /: Failed to open /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/third_party/jstemplate/jstemplate_compiled. js while trying to flatten ../../../../src/3 rdparty/chromium/ui/webui/resources/js/jstemplate_compiled. js. (No such file or directory)
Traceback (most recent call last):File ../../../../src/3 rdparty/chromium/tools/grit/grit. py, line 29, in modulesys.exit (grit. grit_runner.Main (sys. argv[1:]))File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/grit_runner. py, line 314, in Mainreturn toolobject.Run (options, args[1:])File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/tool/build. py, line 274, in Runself.Process ()File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/tool/build. py, line 409, in Processself.ProcessNode (self. res, output, tmpfile)File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/tool/build. py, line 333, in ProcessNodeformatted formatter (node, output_node.GetLanguage (), output_dirbase_dir)File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/format/data_pack. py, line 90, in Formatvalue node.GetDataPackValue (lang, util. BINARY)File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/node/include. py, line 104, in GetDataPackValuedata self._GetFlattenedData (allow_external_scriptallow_external_script)File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/node/include. py, line 41, in _GetFlattenedDataallow_external_scriptallow_external_script))File /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/tools/grit/grit/format/html_inline. py, line 551, in InlineToString(e.filename, input_filename, e.strerror))
Exception: Failed to open /home/geit/Documents/qtwebengine-opensource-src-5.15.2dfsg/src/3 rdparty/chromium/third_party/jstemplate/jstemplate_compiled. js while trying to flatten ../../../../src/3 rdparty/chromium/ui/webui/resources/js/jstemplate_compiled. js. (No such file or directory)jstemplate 库文件缺失 /usr/bin/ld: 找不到 -llcms2
collect 2: error: ld returned 1 exit status
make[3]: *** [Makefile. core_module:90../../lib/libQt 5 WebEngineCore. so. 5.15.2] 错误 1安装
sudo apt install liblcms2-dev其实这个也是由于 rules 文件导致的错误它指定使用系统的 libcms2 库
文件缺失原因
rules
先附上 debian 文件夹下的 rules 文件
#!/usr/bin/make -f# Uncomment this to turn on verbose mode.
#export DH_VERBOSE1
export NINJA_PATH/usr/bin/ninja
export NINJAFLAGS-v
include /usr/share/dpkg/default. mkDEB_HOST_ARCH_BITS ? $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS)# TODO: properly integrate with the other debug setting
ifeq (32,$(DEB_HOST_ARCH_BITS))export DEB_CFLAGS_MAINT_APPEND -g 1export DEB_CXXFLAGS_MAINT_APPEND -g 1
endifexport CFLAGS : $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
export CXXFLAGS : $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
export LDFLAGS : $(shell dpkg-buildflags --get LDFLAGS)
export QT_SELECT : qt 5VERSION_CLEAN_UPSTREAM $(call dpkg_late_eval, VERSION_CLEAN_UPSTREAM, echo $(DEB_VERSION_UPSTREAM) | sed -e s/\(~\|\).*//)DEB_HOST_ARCH ? $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_MULTIARCH ? $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu echo yes))
ifeq ($(DEB_HOST_ARCH), arm 64)export NINJAFLAGS -j 2
endif
endifgstab_architectures :
fulldebug_architectures :
disabled_jit_architectures : armel mips mipsel mips 64 el loongarch 64
disabled_pch_architectures : amd 64 powerpc s 390 xsmall_architectures : armhf mipsel
no_gold_architectures : arm 64 armhf mipsel mips 64 el loongarch 64config_args -proprietary-codecs \-system-webp \touch_files src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/lighthouse-dt-bundle. js \src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/report-assets/report-generator. js \src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/diff/diff_match_patch. js \src/3 rdparty/chromium/third_party/devtools-frontend/src/front_end/formatter_worker/acorn/acorn. js \src/3 rdparty/chromium/third_party/polymer/v 3_0/components-chromium/polymer/polymer_bundled. min. js \src/3 rdparty/chromium/third_party/web-animations-js/sources/web-animations-next-lite. min. js %:dh $ --with pkgkde_symbolshelperoverride_dh_auto_clean:dh_auto_cleanrm -f .qmake. cacherm -f config. tests/. qmake. cacherm -f qtwebengine-config. hrm -rf $(CURDIR)/test_rootrm -rf $(CURDIR)/docsrm -rf $(CURDIR)/. localrm -f $(CURDIR)/src/3 rdparty/chromium/third_party/jstemplate/jstemplate_compiled. jsrm -f $(CURDIR)/src/3 rdparty/chromium/third_party/mocha/mocha. jsrm -f $(CURDIR)/examples/webenginewidgets/contentmanipulation/jquery*. jsfor fname in $(touch_files); do \rm -f $(CURDIR)/$${fname}; \doneoverride_dh_auto_configure:# Run qmake once to create .qmake. conf and be sure to append the following values.qmake QT_BUILD_PARTStests QMAKE_EXTRA_ARGS$(config_args) QMAKE_PYTHON 2python 2# Enable gstabs debugging symbols only on gstab_architectures.
ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(gstab_architectures)))echo QMAKE_CXXFLAGS - -g .qmake. confecho QMAKE_CXXFLAGS -gstabs .qmake. conf
# Enable normal debugging symbols only on fulldebug_architectures.
else ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(fulldebug_architectures)))echo QMAKE_CXXFLAGS_DEBUG -fdebug-types-section .qmake. confecho QMAKE_CXXFLAGS -fdebug-types-section .qmake. confecho QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -fdebug-types-section .qmake. confecho QMAKE_CXXFLAGS_RELEASE -fdebug-types-section .qmake. confecho QMAKE_LFLAGS -fdebug-types-section .qmake. conf
else
# Disable debugging symbols in all the other archs.echo QMAKE_CFLAGS - -g .qmake. confecho QMAKE_CFLAGS - -gstabs .qmake. confecho QMAKE_CXXFLAGS - -g .qmake. confecho QMAKE_CXXFLAGS - -gstabs .qmake. confecho QT_CONFIG - force_debug_info .qmake. confecho QT_CONFIG - separate_debug_info .qmake. conf
endif# Disable JIT on selected architectures
ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(disabled_jit_architectures)))echo QMAKE_CXXFLAGS -DENABLE_JIT0 .qmake. conf
endif# Disable header precompliation as it creates invalid includes on certain
# architectures causing build failure. LP: 1395661
ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(disabled_pch_architectures)))echo CONFIG - precompile_header .qmake. conf
endififeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(small_architectures)))echo QMAKE_CXXFLAGS --param ggc-min-expand20 .qmake. confecho QMAKE_CFLAGS --param ggc-min-expand20 .qmake. confecho QMAKE_LFLAGS - Wl,--gc-sections .qmake. conf
endififeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(no_gold_architectures)))# Do not use ld. goldecho QMAKE_LFLAGS - -fuse-ldgold .qmake. confecho QMAKE_LFLAGS -fuse-ldbfd .qmake. conf
endif# Make ld not cache the symbol tables of input files in memory to avoid memory exhaustion during the linking phase.echo QMAKE_LFLAGS -Wl,--no-keep-memory .qmake. conf# Missing hardening flag detected by blhcecho QMAKE_LFLAGS -Wl,-z, now .qmake. conf# Run qmake again now with the proper values.qmake QT_BUILD_PARTStests QMAKE_EXTRA_ARGS$(config_args) QMAKE_PYTHON 2python 2# Create js files, that are needed for building step for arch and indep buildscd $(CURDIR)/src/3 rdparty/chromium/third_party/jstemplate/; \closure-compiler --compilation_level ADVANCED_OPTIMIZATIONS \--js util. js \--js jsevalcontext. js \--js jstemplate. js \--js exports. js \--js_output_file jstemplate_compiled. jsexamples/webenginewidgets/contentmanipulation/jquery. js cat debian/missing-sources/jquery-*. jsyui-compressor --type js examples/webenginewidgets/contentmanipulation/jquery. js -o examples/webenginewidgets/contentmanipulation/jquery. min. jssrc/3 rdparty/chromium/third_party/mocha/mocha. js tar xaf debian/missing-sources/mocha*. tar. gz --wildcards --to-stdout */mocha. jsset -ex; for fname in $(touch_files); do \mkdir -p $(CURDIR)/$$(dirname $${fname}); \touch $(CURDIR)/$${fname}; \doneoverride_dh_auto_build-arch:dh_auto_build -- -Onone#we also need the resources. pak files, so we need the normal build.
override_dh_auto_build-indep: override_dh_auto_build-archdh_auto_build -- docsoverride_dh_auto_install-arch:dh_auto_install# Remove rpath from the offending binarieschrpath -d $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/qt 5/libexec/QtWebEngineProcess# Fix wrong path in pkgconfig filesfind $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig -type f -name *. pc \-exec sed -i -e s/$(DEB_HOST_MULTIARCH)\/$(DEB_HOST_MULTIARCH)/$(DEB_HOST_MULTIARCH)/g {} \;# Remove libtool-like filesrm -fv debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*. laoverride_dh_auto_install-indep: override_dh_auto_install-archdh_auto_build -- INSTALL_ROOT$(CURDIR)/debian/tmp install_docsoverride_dh_link:dh_link --packageqtwebengine 5-examples \usr/share/javascript/jquery/jquery. min. js usr/lib/$(DEB_HOST_MULTIARCH)/qt 5/examples/webenginewidgets/contentmanipulation/jquery. min. js \usr/share/javascript/marked/marked. min. js usr/lib/$(DEB_HOST_MULTIARCH)/qt 5/examples/webenginewidgets/markdowneditor/resources/marked. jsdh_link --packageqtwebengine 5-dev-tools \usr/lib/qt 5/bin/qwebengine_convert_dict usr/lib/$(DEB_HOST_MULTIARCH)/qt 5/bin/qwebengine_convert_dictdh_link --remaining-packagesoverride_dh_auto_test-arch:$(MAKE) install -Csrc/core INSTALL_ROOT$(CURDIR)/test_root-QTWEBENGINEPROCESS_PATH$(CURDIR)/libexec/QtWebEngineProcess xvfb-run -a \-s -screen 0 1024 x 768 x 24 extension RANDR extension RENDER extension GLX \dh_auto_test --no-parallel -- -k \QML 2_IMPORT_PATH$(CURDIR)/test_root/usr/lib/$(DEB_HOST_MULTIARCH)/qt 5/qml \LD_LIBRARY_PATH$(CURDIR)/liboverride_dh_auto_test-indep:# Do not attempt to run anything to make build-indep work可以看到rules 文件里故意删除了那些文件那么为什么呢后来在 README 文件中找到了答案
原因
xx/qtwebengine-opensource-src-5.15.2dfsg/debian/missing-sources$ cat README
Missing source files
--------------------
QtWebEngine ships embeded minified javascript libraries.
The GPL requires you to provide the corresponding source code.
For Debian all missing sources are bundled in this directory.
They have been grabbed from the various upstream projects.
Last synchronization was made with QtWebEngine v5.9.2 at 2017-09-19.
Files: examples/webenginewidgets/contentmanipulation/jquery.min.js
Project: jQuery v1.3.2
License: Expat or GPL
Source: http://code.jquery.com/jquery-1.3.2.js
Files: examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.min.js
Project: marked 0.3.6
License: Expat
Source: https://github.com/chjj/marked/archive/v0.3.6.tar.gz
Files: examples/webengine/recipebrowser/resources/pages/assets/3rdparty/marked.min.js
Project: marked 0.3.6
License: Expat
Source: https://github.com/chjj/marked/archive/v0.3.6.tar.gz
Files: src/3rdparty/chromium/third_party/mocha/mocha.js
Project: Mocha 2.5.3
License: MIT
Source: https://github.com/mochajs/mocha/archive/v2.5.3.tar.gz 简而言之就是版权问题。
总结
以上便是在国产龙芯 CPU 架构国产 Linux 系统下编译 Qt 源码的整个过程。需要注意的就是要使用已打好patch的源码包即针对 LoongArch 架构适配之后的。
同时要注意使用龙芯提供的源码包时由于 debian 的 rules 文件将一些文件删除了导致使用 Qt 官方编译方式会编译错误所以需要自己补上缺失的文件。当然如果使用 Debian dpkg-buildpackage -us -uc -tc -b的编译方式就不需要了。 https://www.cnblogs.com/tingtaishou/p/17387763.html https://blog.csdn.net/2301_77077496/article/details/133315507 https://www.xssl.online/uos%e7%bc%96%e8%af%91qt-%e9%be%99%e8%8a%af/ https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-CN.html#cc%E9%A2%84%E5%A4%84%E7%90%86%E5%99%A8%E5%86%85%E5%BB%BA%E5%AE%8F%E5%AE%9A%E4%B9%89