将错误与Qt5和c ++ 11链接 - Q_COMPILER_REF_QUALIFIERS [英] Linking error with Qt5 and c++ 11 -- Q_COMPILER_REF_QUALIFIERS
问题描述
我在Qt5(Ubuntu 64bit)中有一个C ++项目。它在我的电脑上正常运行。
我刚刚在我的电脑上重新安装了ubuntu 14.10。我还安装了所有必需的软件包(Qt,其他库)但重建项目时有很多链接错误。
qstring.h:错误:未定义引用` QString :: toUtf8_helper(QString const&)'
qimage.h:错误:未定义引用`QImage :: rgbSwapped_helper()const'
qpixmap.h:错误:未定义引用`QPixmap :: fromImageInPlace(QImage&,QFlags< qt :: imageconversionflag xmlns:qt =#unknown>)'
错误:未定义引用to`QString :: toLocal8Bit_helper(QChar const *,int)'
.......
在qstring.h中,该行包含错误:
#if定义(Q_COMPILER_REF_QUALIFIERS)&& !定义(QT_COMPILING_QSTRING_COMPAT_CPP)
QByteArray toLatin1()const& Q_REQUIRED_RESULT
{return toLatin1_helper(* this); }
................................
#否则
QByteArray toLatin1()const Q_REQUIRED_RESULT;
.......................... .......................
#endif
我的项目使用C ++ 11(我在.pro文件中添加了config + = c ++ 11)。我认为它会导致这些错误。我试过#undef Q_COMPILER_REF_QUALIFIERS但没有工作。
有人能帮助我吗?谢谢!
I have a project C++ in Qt5 (Ubuntu 64bit). It ran normally on my computer.
I have just reinstalled ubuntu 14.10 on my computer. I have also installed all necessary packages (Qt, other libraries) but there are many linking errors when rebuilding my project.
qstring.h: error: undefined reference to `QString::toUtf8_helper(QString const&)'
qimage.h: error: undefined reference to `QImage::rgbSwapped_helper() const'
qpixmap.h: error: undefined reference to `QPixmap::fromImageInPlace(QImage&, QFlags<qt::imageconversionflag xmlns:qt="#unknown">)'
error: undefined reference to `QString::toLocal8Bit_helper(QChar const*, int)'
.......
In qstring.h, the line contains errors :
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP)
QByteArray toLatin1() const & Q_REQUIRED_RESULT
{ return toLatin1_helper(*this); }
................................
#else
QByteArray toLatin1() const Q_REQUIRED_RESULT;
.................................................
#endif
My project use C++ 11 ( I have added config += c++11 in .pro file).I think it causes these errors. I tried #undef Q_COMPILER_REF_QUALIFIERS but not working.
Can anybody help me ? Thanks !
推荐答案
Q_COMPILER_REF_QUALIFIERS
根据使用情况在 qcompilerdetection.h 中设置编译器和常规设置。因此不应该更改。
要忽略该设置,请定义QT_COMPILING_QSTRING_COMPAT_CPP
(如您的摘录所示) qstring.h 的)。可能还需要定义其他兼容性定义,例如QT_COMPILING_QIMAGE_COMPAT_CPP
。
Q_COMPILER_REF_QUALIFIERS
is set in qcompilerdetection.h according to the used compiler and general settings. So it should not be changed.
To ignore the setting, defineQT_COMPILING_QSTRING_COMPAT_CPP
(as indicated by your excerpt from qstring.h). It may be also necessary to define other compatibility definitions likeQT_COMPILING_QIMAGE_COMPAT_CPP
.
这篇关于将错误与Qt5和c ++ 11链接 - Q_COMPILER_REF_QUALIFIERS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!