【问题标题】:Qt requires C++11 support" make errorQt 需要 C++11 支持”出错
【发布时间】:2016-10-20 05:09:34
【问题描述】:

我尝试按照 README.md 中的说明从源代码编译最新的平铺。

我的工作环境:

平铺源代码:平铺-0.16.1

Mac 操作系统:10.11.1

Xcode:7.1

QMake:3.0

Qt:5.7.0

苹果 LLVM:7.0.0

但是 make 失败并出现以下错误:

In file included from pythonplugin.cpp:21:
In file included from ./pythonplugin.h:30:
In file included from ../../libtiled/logginginterface.h:33:
In file included from ../../libtiled/tiled_global.h:32:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:1145:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qatomic.h:46:
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:61:4: error: "Qt requires C++11 support"
#  error "Qt requires C++11 support"
   ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:90:13: error: unknown type name 'QAtomicOps'
    typedef QAtomicOps<T> Ops;
            ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:90:23: error: expected member name or ';' after declaration
      specifiers
    typedef QAtomicOps<T> Ops;
    ~~~~~~~~~~~~~~~~~~^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:93:23: error: use of undeclared identifier 'QAtomicOpsSupport'
    Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
                      ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:746:66: note: expanded from macro 'Q_STATIC_ASSERT_X'
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
                                                                 ^
In file included from pythonplugin.cpp:21:
In file included from ./pythonplugin.h:30:
In file included from ../../libtiled/logginginterface.h:33:
In file included from ../../libtiled/tiled_global.h:32:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:1145:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qatomic.h:46:
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:93:53: error: no member named 'IsSupported' in the global
      namespace
    Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
                                                  ~~^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:746:66: note: expanded from macro 'Q_STATIC_ASSERT_X'
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
                                                                 ^
In file included from pythonplugin.cpp:21:
In file included from ./pythonplugin.h:30:
In file included from ../../libtiled/logginginterface.h:33:
In file included from ../../libtiled/tiled_global.h:32:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:1145:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qatomic.h:46:
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:95:14: error: use of undeclared identifier 'Ops'
    typename Ops::Type _q_value;
             ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:95:19: error: expected a qualified name after 'typename'
    typename Ops::Type _q_value;
                  ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:95:23: error: expected ';' at end of declaration list
    typename Ops::Type _q_value;
                      ^
                      ;
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:99:44: error: use of undeclared identifier 'Ops'
    T load() const Q_DECL_NOTHROW { return Ops::load(_q_value); }
                                           ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:99:54: error: use of undeclared identifier '_q_value'
    T load() const Q_DECL_NOTHROW { return Ops::load(_q_value); }
                                                     ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:100:45: error: use of undeclared identifier 'Ops'
    void store(T newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); }
                                            ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:100:56: error: use of undeclared identifier '_q_value'
    void store(T newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); }
                                                       ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:102:51: error: use of undeclared identifier 'Ops'
    T loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); }
                                                  ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:102:68: error: use of undeclared identifier '_q_value'
    T loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); }
                                                                   ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:103:52: error: use of undeclared identifier 'Ops'
    void storeRelease(T newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); }
                                                   ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:103:70: error: use of undeclared identifier '_q_value'
    void storeRelease(T newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); }
                                                                     ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:107:86: error: use of undeclared identifier 'Ops'
    static Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); }
                                                                                     ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:107:34: error: no return statement in constexpr function
    static Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); }
                                 ^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:108:88: error: use of undeclared identifier 'Ops'
    static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return Ops::isReferenceCountingWaitFree(); }
                                                                                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[3]: *** [pythonplugin.o] Error 1
make[2]: *** [sub-python-make_first] Error 2
make[1]: *** [sub-plugins-make_first-ordered] Error 2
make: *** [sub-src-make_first-ordered] Error 2

经过一番研究,我尝试在tiled.pro 文件中添加一行CONFIG+= c++11,然后make clean、qmake、make,但我仍然遇到同样的错误......

平铺.pro:

# Check the Qt version. If QT_VERSION is not set, it is probably Qt 3.
isEmpty(QT_VERSION) {
    error("QT_VERSION not defined. Tiled does not work with Qt 3.")
}

include(tiled.pri)

!minQtVersion(5, 1, 0) {
    message("Cannot build Tiled with Qt version $${QT_VERSION}")
    error("Use at least Qt 5.1.0.")
}

TEMPLATE  = subdirs
CONFIG   += ordered
CONFIG   += c++11

SUBDIRS = src translations

不知道这里出了什么问题。

任何建议将不胜感激,谢谢:)

更新:

试过了

QMAKE_CXXFLAGS += -std=c++11

QMAKE_CXXFLAGS += -std=c++0x

还是一样的错误......

我想可能是在C++编译make命令使用,这里是一些资料:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c `python-config --cflags` -O2 -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.8 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DPYTHON_LIBRARY -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../libtiled -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib/QtWidgets.framework/Headers -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib/QtGui.framework/Headers -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/mkspecs/macx-clang -F/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib -o pythonplugin.o pythonplugin.cpp

【问题讨论】:

  • 也试试QMAKE_CXXFLAGS += -std=c++11
  • 也可以试试QMAKE_CXXFLAGS += -std=c++0x
  • 感谢您的快速回答尝试了两个标志,但仍然有相同的错误。请查看此问题的更新信息。
  • 你试过编译其他项目吗?如果没有,您可能需要打开 Xcode 并接受其许可协议或在终端中运行它:xcode-select --install

标签: c++ qt c++11


【解决方案1】:

我在使用 Qt 包装器构建 poppler 时遇到了类似的问题,并且得到了同样的错误:“Qt 需要 C++11 支持”。

我的设置是:

Mac OS: 10.11.5
Xcode : 7.3.1
QMake: 3.0
Qt: 5.7.0
Apple LLVM: 7.3.0

我所做的只是:

export CXXFLAGS=-std=c++11
./configure 
make

它成功了。

【讨论】:

    【解决方案2】:

    我知道已经有一段时间了。 我最终解决这个问题的方法是在 CMakeLists.txtproject(MyProject) 之后添加以下行:

    add_compile_options(-std=c++11)
    

    这对 cmake 说,创建一个 Makefile 将使用 c++11 解决问题。

    【讨论】:

      猜你喜欢
      • 2017-01-16
      • 2017-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-19
      • 1970-01-01
      • 2016-02-24
      相关资源
      最近更新 更多