Click here to Skip to main content
15,888,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 !
Posted
Updated 9-Dec-14 17:02pm
v2
Comments
Zero_J 24-Mar-16 5:54am    
Hi shang,
I have kind of same problem with you, can you share your solving way with me?
Thank you!

this is my error :
/home/darwin/catkin_ws/src/leddar/lib/libLeddar.so: undefined reference to `QString::toLocal8Bit_helper(QChar const*, int)'
/home/darwin/catkin_ws/src/leddar/lib/libLeddarC.so: undefined reference to `QString::toUtf8_helper(QString const&)'

1 solution

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, define QT_COMPILING_QSTRING_COMPAT_CPP (as indicated by your excerpt from qstring.h). It may be also necessary to define other compatibility definitions like QT_COMPILING_QIMAGE_COMPAT_CPP.
 
Share this answer
 
Comments
shang12 11-Dec-14 2:28am    
I want to know which cause errors.
I tested my project on some computers (all same Ubuntu 14.10 and Qt 5.3.2) and it ran normally.
Don't need to add #define.
My project has many files (use QString, QImage, QPixmap,....), it is very inconvenient to add #define to them.
Jochen Arndt 11-Dec-14 3:46am    
I don't know what causes the error in your setup (but the c++11 option seems to be reasonable). To find out, inspect the qcompilerdetection.h file.

You should never edit library header files.

If your project has a project specific include file, add the definition there. This file must then be included first in all your source files.

Alternatively set the definition by passing it to the compiler using the .pro file (for gcc and most other compilers):
QMAKE_CXXFLAGS += -DQT_COMPILING_QSTRING_COMPAT_CPP
shang12 11-Dec-14 9:51am    
Thank for your help.
Now, I have reinstalled Ubuntu, gcc and Qt. My project has built successfully.
Zero_J 24-Mar-16 5:30am    
Hi shang,
I have kind of same problem with you, can you share your solving way with me?
Thank you!

this is my error :
/home/darwin/catkin_ws/src/leddar/lib/libLeddar.so: undefined reference to `QString::toLocal8Bit_helper(QChar const*, int)'
/home/darwin/catkin_ws/src/leddar/lib/libLeddarC.so: undefined reference to `QString::toUtf8_helper(QString const&)'
Jochen Arndt 24-Mar-16 5:44am    
He won't read this because you have posted a comment to my solution.
But according to his above comment he has solved it:

"Now, I have reinstalled Ubuntu, gcc and Qt. My project has built successfully."

So it seems it was sourced by updating / reinstalling some - but not all - involved components.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900