【问题标题】:Compiling Qt5 on MacOS with gcc-8 instead of clang在 MacOS 上使用 gcc-8 而不是 clang 编译 Qt5
【发布时间】:2019-04-23 22:47:13
【问题描述】:

我正在尝试在 MacOS 上编译 Qt5,使用 gcc-8 而不是默认的 clang。从本指南here 我已经能够使用以下方法进行配置:

CC=gcc-8 CXX=g++-8 CFORT=gfortran-8 ../configure --prefix=/Users/qth20/Utilities/qt-5.12 -opensource -nomake examples -nomake tests -platform g++-8

但是当我检查详细输出时:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -c -pipe -g -fPIC -std=gnu11  -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.12 -fvisibility=hidden -w -fno-exceptions -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DPNG_ARM_NEON_OPT=0 -DPNG_POWERPC_VSX_OPT=0 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -isystem /Users/qth20/qt5/qtbase/src/3rdparty/libpng -I. -isystem /Users/qth20/qt5/qtbase/src/3rdparty/libpng -I/Users/qth20/qt5/qtbase/mkspecs/macx-clang -o .obj/debug/pngmem.o /Users/qth20/qt5/qtbase/src/3rdparty/libpng/pngmem.c

它似乎仍在使用clang 而不是gcc-8。有什么建议可以解决这个问题?

【问题讨论】:

    标签: c++ macos gcc qt5


    【解决方案1】:

    只需使用 macos-g++ 平台: ../configure -platform macos-g++

    但不能保证一切都是开箱即用的。

    【讨论】:

    • 请注意,要设置编译器,您需要设置QMAKE_CC和QMAKE_CXX,并将它们的设置作为参数进行配置,而不是通过设置环境变量。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    • 2023-04-07
    相关资源
    最近更新 更多