这个问题的所有解决方案都归结为
在CONFIG += c++11
文件中使用.pro
或使用QMAKE_CXXFLAGS += -std=c++11
。不幸的是,这些解决方案都不适合我。我仍然得到错误。我必须补充说,我必须将此项目从Linux Ubuntu 16.04 LTS
计算机移动到Mac macOS Sierra 10.12
计算机。移动后错误开始发生。正如您将从输出中看到的那样,我正在运行Qt 5.6.2
以下是我的.pro
文件
#-------------------------------------------------
#
# Project created by QtCreator 2016-10-05T10:30:33
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = gui
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
CONFIG += c++11
QMAKE_CXXFLAGS += -ferror-limit=1
这是运行和失败的实际命令:
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -ferror-limit=1 -g -std=gnu++0x -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../gui -I. -I/usr/local/Cellar/qt5/5.6.2/lib/QtWidgets.framework/Headers -I/usr/local/Cellar/qt5/5.6.2/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt5/5.6.2/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/usr/local/Cellar/qt5/5.6.2/mkspecs/macx-g++ -F/usr/local/Cellar/qt5/5.6.2/lib -o main.o ../gui/main.cpp
In file included from ../gui/main.cpp:1:
In file included from ../gui/mainwindow.h:4:
In file included from /usr/local/Cellar/qt5/5.6.2/lib/QtWidgets.framework/Headers/QMainWindow:1:
In file included from /usr/local/Cellar/qt5/5.6.2/lib/QtWidgets.framework/Headers/qmainwindow.h:37:
In file included from /usr/local/Cellar/qt5/5.6.2/lib/QtWidgets.framework/Headers/qwidget.h:38:
In file included from /usr/local/Cellar/qt5/5.6.2/lib/QtCore.framework/Headers/qobject.h:41:
/usr/local/Cellar/qt5/5.6.2/lib/QtCore.framework/Headers/qstring.h:756:55: error: no type named 'u16string' in namespace 'std'
static inline QString fromStdU16String(const std::u16string &s);
~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
这是输出
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin