Qt编译报错:
…/…/…/include/QtCore/…/…/src/corelib/global/qglobal.h:1172:1:
warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName,
bool *ok=nullptr) Q_DECL_NOEXCEPT; ^ In file included from
…/…/…/include/QtCore/qbasicatomic.h:1:0,
from …/…/…/include/QtCore/…/…/src/corelib/thread/qatomic.h:46,
from …/…/…/include/QtCore/qatomic.h:1,
from …/…/…/include/QtCore/…/…/src/corelib/global/qglobal.h:1210,
from …/…/…/include/QtCore/qglobal.h:1,
from …/…/…/include/QtGui/…/…/src/gui/kernel/qtguiglobal.h:43,
from …/…/…/include/QtGui/qtguiglobal.h:1,
from …/…/…/include/QtWidgets/…/…/src/widgets/kernel/qtwidgetsglobal.h:43,
from …/…/…/include/QtWidgets/qtwidgetsglobal.h:1,
from …/…/…/include/QtWidgets/…/…/src/widgets/kernel/qapplication.h:43,
from …/…/…/include/QtWidgets/qapplication.h:1,
from …/…/…/include/QtWidgets/QApplication:1,
from main.cpp:51: …/…/…/include/QtCore/…/…/src/corelib/thread/qbasicatomic.h:61:4:
error: #error “Qt requires C++11 support” # error “Qt requires C++11
support”
处理方法1
单个模组可以直接修改pro:
QMAKE_CXXFLAGS += -std=c++11
或者直接修改makefile:
CFLAGS += -std=c++11
CXXFLAGS += -std=c++11
处理方法2
交叉编译配置添加:
qt\qt-everywhere-src-5.12.5\qtbase\mkspecs\linux-aarch64-gnu-g++\qmake.conf
QMAKE_CFLAGS +=-std=c++11
QMAKE_CXXFLAGS +=-std=c++11
修改qmake.conf之后,不需要重新交叉编译Qt库,直接make就可以自动更新这些参数。