如何配置 QT 5.15.16 以使用 C++20 而不是 С++17?

问题描述 投票:0回答:1

我尝试将 C++20 与 Qt 一起使用,但无论我做什么,它总是默认为 C++17。

以下是配置后输出的相关部分:

# head config.summary
Build type: linux-g++ (x86_64, CPU features: mmx sse sse2)
Compiler: gcc 13.1.0
Configuration: sse2 aesni sse3 ssse3 sse4_1 sse4_2 avx avx2 avx512f
 avx512bw avx512cd avx512dq avx512er avx512ifma avx512pf avx512vbmi
 avx512vl compile_examples enable_new_dtags f16c largefile precompile_header
 rdrnd rdseed shani x86SimdAlways shared shared rpath release 
c++11 c++14 c++17 c++1z concurrent dbus reduce_exports reduce_relocations stl

Build options:
  Using C standard ....................... C11
  Using C++ standard ..................... C++17

Dockerfile。我正在 Docker 容器中运行以下命令:

FROM ubuntu:18.04

# Install gcc-13 PPA
RUN echo "deb [trusted=yes] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic main" > /etc/apt/sources.list.d/ubuntu-toolchain-r-test.list && \
    apt update && \
    apt install -y --no-install-recommends gcc-13 g++-13 && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \
    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100

WORKDIR /opt/build

RUN sed -i 's|# deb|deb|' /etc/apt/sources.list && \
    apt update && \
    apt install -y --no-install-recommends git libedit-dev libopenal-data libsndio-dev libopenal1 libopenal-dev pulseaudio libpthread-workqueue-dev && \
    apt build-dep -y qtbase-opensource-src && \
    apt-get purge -y gcc-7 g++-7 cpp-7 gcc-7-base && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \
    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100 && \
    apt install -y wget xz-utils && \
    wget -P /opt/ https://cdimage.debian.org/mirror/qt.io/qtproject/archive/qt/5.15/5.15.16/single/qt-everywhere-opensource-src-5.15.16.tar.xz && \
    tar -xf /opt/qt-everywhere-opensource-src-5.15.16.tar.xz -C /opt/

构建步骤。启动容器后,我运行以下命令:

docker run -it --rm IAMGENAME bash
export CXXFLAGS="-std=c++20"
../qt-everywhere-src-5.15.16/configure -bundled-xcb-xinput -xcb -xcb-xlib -pulseaudio -alsa -opensource -confirm-license  -recheck-all -v -nomake tests -nomake examples

但是,配置始终默认为 C++17,如 config.summary 文件中所示。

如何配置以使用 C++20 标准?

任何帮助将不胜感激!

qt gcc build c++20
1个回答
0
投票

这应该有效

../qt-everywhere-src-5.15.16/configure -c++std c++20 -bundled-xcb-xinput -xcb -xcb-xlib -pulseaudio -alsa -opensource -confirm-license  -recheck-all -v -nomake tests -nomake examples

有趣的是,我在 Qt 配置手册中找不到该选项。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.