<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>阁下 - 5.15.2</title>
<link>https://liar.org.cn/index.php/tag/5-15-2/</link>
<atom:link href="https://liar.org.cn/index.php/feed/tag/5-15-2/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description></description>
<lastBuildDate>Sun, 11 Oct 2026 09:42:00 +0000</lastBuildDate>
<pubDate>Sun, 11 Oct 2026 09:42:00 +0000</pubDate>
<item>
<title>Openeuler 24.03 源码编译Qt 5.15.2</title>
<link>https://liar.org.cn/index.php/archives/85/</link>
<guid>https://liar.org.cn/index.php/archives/85/</guid>
<pubDate>Sun, 11 Oct 2026 09:42:00 +0000</pubDate>
<dc:creator>Lewis Ho</dc:creator>
<description><![CDATA[GCC、G++、CMake、Make、tar等基础工具独立安装，不包含在后续依赖安装过程中gcc、g++建议使用目标平台提供的默认版本，不要使用高版本，容易因兼容问题导致编译出错因使用不同的g+...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<blockquote><p>GCC、G++、CMake、Make、tar等基础工具独立安装，不包含在后续依赖安装过程中</p><p>gcc、g++建议使用目标平台提供的默认版本，不要使用高版本，容易因兼容问题导致编译出错</p><p>因使用不同的g++版本等原因，编译过程中需要根据报错对Qt源码存在的BUG进行修复。</p></blockquote><p><strong>编译构建分阶段进行：</strong></p><p><strong>- 基础SDK构建，编译构建重量级组件以外的基本内容，环境资源要求低、速度快</strong></p><p><strong>- 构建重量级组件，如QWebEngine，使用构建好的基础SDK进行编译构建</strong></p><h1>依赖安装</h1><h2>基础依赖</h2><pre><code>dnf install -y \
    perl \
    bison \
    flex \
    gperf \
    ruby \
    pkgconf-pkg-config \
    git \
    wget \
    tar \
    xz \
    libstdc++-static</code></pre><p>检查：</p><pre><code>gcc --version
g++ --version
perl --version
bison --version
flex --version
gperf --version</code></pre><h3>安装Python</h3><blockquote><strong>Qt 5.15.2 需要Python 2.x</strong></blockquote><p>手动下载Python2源码包:</p><pre><code class="lang-shell">curl -LO https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
tar xf Python-2.7.18.tgz
cd Python-2.7.18</code></pre><p>构建并安装：</p><pre><code class="lang-shell">./configure \
    --prefix=/opt/python/2.7 \
    --enable-unicode=ucs4
    
make -j$(nproc)
make install

# 检查版本
/opt/python/2.7/bin/python2.7 --version

# 建立软连接
ln -sf /opt/python/2.7/bin/python /usr/bin/python
ln -sf /opt/python/2.7/bin/python /usr/bin/python2

# 导出到环境变量(临时)
export PATH=/opt/python/2.7/bin:$PATH</code></pre><h3>Qt GUI/X11 依赖</h3><pre><code>dnf install -y \
    mesa-libGL-devel \
    mesa-libEGL-devel \
    libX11-devel \
    libxcb-devel \
    libXext-devel \
    libXfixes-devel \
    libXi-devel \
    libXrender-devel \
    libXrandr-devel \
    libXcursor-devel \
    libXinerama-devel \
    libXcomposite-devel \
    libxcb-devel \
    xcb-util-devel \
    xcb-util-image-devel \
    xcb-util-keysyms-devel \
    xcb-util-renderutil-devel \
    xcb-util-wm-devel</code></pre><p>然后：</p><pre><code>dnf install -y \
    fontconfig-devel \
    freetype-devel \
    harfbuzz-devel \
    libpng-devel \
    libjpeg-turbo-devel</code></pre><h3>OpenGL / 输入设备相关</h3><pre><code>dnf install -y \
    libinput-devel \
    libudev-devel \
    dbus-devel \
    dbus-libs \
    alsa-lib-devel</code></pre><h3>OpenSSL</h3><p>如果需要使用：</p><pre><code>QtNetwork
QSslSocket
HTTPS
TLS</code></pre><p>则安装：</p><pre><code>dnf install -y \
    openssl-devel</code></pre><p>确认：</p><pre><code>openssl version</code></pre><h3>SQLite / PostgreSQL / MySQL</h3><p>如果需要 Qt SQL 插件尽可能完整，可以安装：</p><pre><code>dnf install -y \
    sqlite-devel</code></pre><p>如果需要 PostgreSQL：</p><pre><code>dnf install -y \
    postgresql-devel</code></pre><p>MySQL/MariaDB：</p><pre><code>dnf install -y \
    mariadb-connector-c-devel</code></pre><h2>QWebEngine依赖</h2><blockquote>已剔除前序安装过的依赖项</blockquote><pre><code class="lang-shell">sudo dnf install -y \
    nss-devel \
    nspr-devel \
    pciutils-devel \
    ninja-build \
    cups-devel \
    pulseaudio-libs-devel \
    libcap-devel \
    libXtst-devel \
    libXScrnSaver-devel \
    libdrm-devel \
    libxkbcommon-devel \
    expat-devel</code></pre><h3>安装Node.js</h3><blockquote><strong>5.15.2应当使用Node.js 12.18.0</strong></blockquote><p>下载：</p><pre><code class="lang-shell">wget https://nodejs.org/dist/v12.18.0/node-v12.18.0-linux-x64.tar.xz</code></pre><p>安装：</p><pre><code class="lang-shell">sudo mkdir -p /opt/node
sudo tar -xJf node-v12.18.0-linux-x64.tar.xz -C /opt/node</code></pre><pre><code class="lang-shell"># 导出到环境变量（临时）
export PATH=/opt/node/node-v12.18.0-linux-x64/bin:$PATH</code></pre><p>检查：</p><pre><code class="lang-shell">which node
node --version

which npm
npm --version</code></pre><p>应该得到：</p><pre><code>/opt/node/node-v12.18.0-linux-x64/bin/node
v12.18.0

/opt/node/node-v12.18.0-linux-x64/bin/npm
6.14.4</code></pre><h1>源码兼容</h1><blockquote>一些在编译构建过程中会遇到的源码或构建工具链兼容性问题。</blockquote><h2>找不到std::max</h2><p>找不到std::max等问题，直接在相关文件中增加<strong>#include <limits></strong></p><pre><code class="lang-shell"># 包括以下文件
vim ~/qt-everywhere-src-5.15.2/qtbase/src/corelib/global/qfloat16.h
vim ~/qt-everywhere-src-5.15.2/qtbase/src/corelib/text/qbytearraymatcher.h
vim ~/qt-everywhere-src-5.15.2/qtdeclarative/src/qmldebug/qqmlprofilerevent_p.h
vim ~/qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/containers/string_pool.h</code></pre><h2>XCB兼容问题</h2><pre><code class="lang-shell">cd ~/qt-everywhere-src-5.15.2/qtbase/src/platformsupport/input/xkbcommon

python3 - &lt;&lt;&#039;PY&#039;
from pathlib import Path

p = Path(&quot;qxkbcommon.cpp&quot;)
s = p.read_text()

anchor = &#039;#include &quot;qxkbcommon_p.h&quot;&#039;

compat = &quot;&quot;&quot;
// Compatibility definitions for older libxkbcommon headers.
#ifndef XKB_KEY_dead_lowline
#define XKB_KEY_dead_lowline 0xfe90
#endif

#ifndef XKB_KEY_dead_aboveverticalline
#define XKB_KEY_dead_aboveverticalline 0xfe91
#endif

#ifndef XKB_KEY_dead_belowverticalline
#define XKB_KEY_dead_belowverticalline 0xfe92
#endif

#ifndef XKB_KEY_dead_longsolidusoverlay
#define XKB_KEY_dead_longsolidusoverlay 0xfe93
#endif
&quot;&quot;&quot;

if anchor not in s:
    raise SystemExit(&quot;错误：未找到插入位置，文件未修改。&quot;)

if &quot;Compatibility definitions for older libxkbcommon headers.&quot; in s:
    raise SystemExit(&quot;兼容性定义已经存在，未重复修改。&quot;)

s = s.replace(anchor, anchor + &quot;\n&quot; + compat, 1)
p.write_text(s)

print(&quot;已添加兼容性定义。&quot;)
PY</code></pre><h2>QWebEngine编译</h2><pre><code class="lang-shell">#原为
static const unsigned kSigStackSize = std::max(16384, SIGSTKSZ);

#改为
static const unsigned kSigStackSize =
    static_cast&lt;unsigned&gt;(std::max&lt;unsigned&gt;(16384, SIGSTKSZ));

#修改下述文件: 
vim ~/qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc</code></pre><h2>ffmpeg汇编问题</h2><p>编译错误信息如下：</p><pre><code class="lang-shell">../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/autorename_libavcodec_flacdec.c -o obj/third_party/ffmpeg/ffmpeg_internal/autorename_libavcodec_flacdec.o
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h: Assembler messages:
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:116: 错误：operand type mismatch for `sar&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
../../../qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h:125: 错误：operand type mismatch for `shr&#039;
</code></pre><pre><code class="lang-shell">
#修改下述文件
vim /root/qt-everywhere-src-5.15.2/qtwebengine/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h

修改内容：将&quot;ic&quot;修改为&quot;c&quot;
static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
    __asm__ (&quot;sarl %1, %0\n\t&quot;
         : &quot;+r&quot; (a)
         : &quot;c&quot; ((uint8_t)(-s))
    );
    return a;
}

#define NEG_USR32 NEG_USR32
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
    __asm__ (&quot;shrl %1, %0\n\t&quot;
         : &quot;+r&quot; (a)
         : &quot;c&quot; ((uint8_t)(-s))
    );
    return a;
}</code></pre><h1>构建</h1><p><strong>不要在源码目录里面构建。</strong></p><h2>基础SDK构建</h2><p>创建独立构建目录：</p><pre><code class="lang-shell">mkdir -p ~/qt-build/5.15.2-openeuler-24.03-x86_64/base</code></pre><p>创建安装目录：</p><pre><code class="lang-shell">mkdir -p /opt/qt/5.15.2/openeuler-24.03-x86_64</code></pre><p>进入构建目录：</p><pre><code class="lang-shell">cd ~/qt-build/5.15.2-openeuler-24.03-x86_64/base</code></pre><p>配置Qt：</p><pre><code class="lang-shell">~/qt-everywhere-src-5.15.2/configure \
    -prefix /opt/qt/5.15.2/openeuler-24.03-x86_64 \
    -opensource \
    -confirm-license \
    -release \
    -force-debug-info \
    -separate-debug-info \
    -shared \
    -nomake examples \
    -nomake tests \
    -skip qtwebengine \
    -skip qtwebview</code></pre><p>参数说明：</p><p><code>-prefix</code> 指定最终 SDK 安装位置。</p><pre><code>-prefix /opt/qt/5.15.2/openeuler-24.03-x86_64</code></pre><p><code>-opensource</code> 使用开源版本</p><p><code>-confirm-license</code> 自动接受开源许可证确认</p><p><code>-release</code> 构建 Release Qt</p><p><code>-force-debug-info</code> 生成Qt自身的调试信息</p><p><code>-separate-debug-info</code> 调试信息独立存储</p><p><code>-shared</code> </p><p>构建:</p><pre><code class="lang-shell">gmake -j$(nproc)</code></pre><p>安装：</p><pre><code class="lang-shell">make install</code></pre><h4>验证qmake</h4><pre><code>/opt/qt/5.15.2/openeuler-24.03-x86_64/bin/qmake -v
/opt/qt/5.15.2/openeuler-24.03-x86_64/bin/moc -v
/opt/qt/5.15.2/openeuler-24.03-x86_64/bin/uic -v
/opt/qt/5.15.2/openeuler-24.03-x86_64/bin/rcc -v</code></pre><h2>构建WebEngine</h2><p>创建独立构建目录：</p><pre><code class="lang-shell">mkdir -p ~/qt-build/5.15.2-openeuler-24.03-x86_64/webengine</code></pre><p>创建安装目录：</p><pre><code class="lang-shell">mkdir -p /opt/qt/5.15.2/openeuler-24.03-x86_64</code></pre><p>进入构建目录：</p><pre><code class="lang-shell">cd ~/qt-build/5.15.2-openeuler-24.03-x86_64/webengine</code></pre><p>使用已经编译好的基础版本Qt:</p><pre><code class="lang-shell">export QT_ROOT=/opt/qt/5.15.2/openeuler-24.03-x86_64
export PATH=$QT_ROOT/bin:$PATH
export LD_LIBRARY_PATH=$QT_ROOT/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=&quot;$QT_ROOT/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}&quot;
export CMAKE_PREFIX_PATH=&quot;$QT_ROOT${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}&quot;</code></pre><p>配置务必和基础SDK配置保持一致：</p><pre><code class="lang-shell">&quot;$QT_ROOT/bin/qmake&quot; \
    ~/qt-everywhere-src-5.15.2/qtwebengine \
    CONFIG+=release \
    CONFIG+=shared \
    CONFIG+=force_debug_info \
    CONFIG+=separate_debug_info</code></pre><p>这里：</p><pre><code>-prefix &quot;$QT_ROOT&quot;</code></pre><p>非常重要。</p><p>它告诉 WebEngine：</p><blockquote>最终安装位置就是我之前已经安装好的 Qt SDK。</blockquote><p>所以：</p><pre><code>Qt 基础模块
        ↓
/opt/qt/5.15.2/openeuler-24.03-x86_64

QtWebEngine
        ↓
/opt/qt/5.15.2/openeuler-24.03-x86_64</code></pre><p>配置完成后，<strong>不要马上开始编译</strong>。</p><p>先检查它是否找到了已有 Qt。</p><p>可以看配置输出，或者：</p><pre><code>grep -R &quot;QT_INSTALL_PREFIX&quot; config.summary config.log 2&gt;/dev/null</code></pre><p>更直接的是检查：</p><pre><code>qmake -query</code></pre><p>确保当前使用的是：</p><pre><code>QT_VERSION:5.15.2</code></pre><p>以及：</p><pre><code>QT_INSTALL_PREFIX:/opt/qt/5.15.2/openeuler-24.03-x86_64</code></pre><p>构建安装：</p><pre><code class="lang-shell">gmake -j$(nproc)
make install</code></pre><h3>安装后检查</h3><p>首先：</p><pre><code>find &quot;$QT_ROOT&quot; -iname &#039;*WebEngine*&#039; -o -iname &#039;*webengine*&#039;</code></pre><p>重点应该能看到：</p><pre><code>$QT_ROOT/bin/QtWebEngineProcess

$QT_ROOT/include/QtWebEngine
$QT_ROOT/include/QtWebEngineCore
$QT_ROOT/include/QtWebEngineWidgets

$QT_ROOT/lib/libQt5WebEngine.so
$QT_ROOT/lib/libQt5WebEngineCore.so
$QT_ROOT/lib/libQt5WebEngineWidgets.so</code></pre><h4>检查 WebEngine 的 Chromium 资源</h4><p>这个非常重要。</p><p>执行：</p><pre><code>find &quot;$QT_ROOT&quot; \
    \( -name &#039;*.pak&#039; -o -name &#039;*icudtl*&#039; \) \
    -print</code></pre><p>应该能找到 WebEngine 相关资源。</p><p>同时：</p><pre><code>find &quot;$QT_ROOT&quot; -name &#039;QtWebEngineProcess&#039;</code></pre><p>必须存在。</p><p>因为：</p><blockquote><strong>只看到 <code>libQt5WebEngineCore.so</code> 并不能证明 WebEngine SDK 安装完整。</strong></blockquote>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://liar.org.cn/index.php/archives/85/#comments</comments>
<wfw:commentRss>https://liar.org.cn/index.php/feed/tag/5-15-2/</wfw:commentRss>
</item>
</channel>
</rss>