Errors while linking in Qt5 with poppler - c++

/usr/lib/libpoppler.so.50: undefined reference to std::__throw_out_of_range_fmt(char const*, ...)#GLIBCXX_3.4.20'
Makefile:156: recipe for target 'DocViewer' failed
/usr/lib/libsystemd.so.0: undefined reference tolzma_stream_decoder#XZ_5.0'
/usr/lib/libQt5Core.so: undefined reference to __cxa_throw_bad_array_new_length#CXXABI_1.3.8'
/usr/lib/libsystemd.so.0: undefined reference tolzma_end#XZ_5.0'
/usr/lib/libsystemd.so.0: undefined reference to `lzma_code#XZ_5.0'
collect2: error: ld returned 1 exit status
make: *** [DocViewer] Error 1
20:53:35: The process "/usr/bin/make" exited with code 2.
I get the errors mentioned above while compiling a program using poppler in Qt5.
Below is my project file, should in change something?
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = DocViewer
TEMPLATE = app
INCLUDEPATH += /usr/include/poppler/qt5
LIBS += -L/usr/lib -lpoppler-qt5
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui

For the "__cxa_throw_bad_array_new_length#CXXABI_1.3.8" error in libicu, it looks like the problem is an incompatible icu build (softfp vs hardfp).
I had the same error, which I solved by downloading a rebuilt ICU (to avoid rebuilding it myself).
Download the "POT" binaries from
http://thebugfreeblog.blogspot.fr/2016/12/binaries-for-pot-550-beta1-on-qt-580.html.
lrzuntar the file
tar xf qtdeps.tar
on the device, move away libicu* (in my case with raspbian it was in usr/lib/arm-linux-gnueabihf), and transfer the libicu* from qtdeps over there
on the device, move away the "unicode" include dir (with raspbian it was in /usr/include/arm-linux-gnueabihf/unicode), and copy the unicode include dir from qtdeps over there.
re-sync from the device to your sysroot using rsync
reconfigure and rebuilt qtbase (after removing the .o files under qtbase/src/corelib that contain "icu" in the name - or rebuild Qt from scratch)

Related

Getting :-1: error: [Makefile.Debug:71: debug/Tappian_Ball.exe] Error 1 when trying to use LIBS

I am getting :-1: error: [Makefile.Debug:71: debug/Tappian_Ball.exe] Error 1 when trying to use LIBS += -framework <KF5Solid>
I want to add KDE Solid to my project and these 2 lines are actually responsible for that
QMAKE_CXXFLAGS+= -F/$$_PRO_FILE_PWD_/KF5Solid/
LIBS += -framework <KF5Solid>
Maybe the problem is in KF5Solid directory, I downloaded source code from here, unpacked it to the source code folder
Qt 5.14.2
Windows 10
MinGW 32-bit

Qt Creator: Release build won't compile

I've written a relatively simple Qt program that I'm trying to compile for windows with MinGW under Qt Creator. The Debug version builds and runs without problem, but when I try to build the Release version I get these errors
main.cpp:-1: error: undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
main.cpp:-1: error: undefined reference to `_imp___ZN7QWidget4showEv'
main.cpp:-1: error: undefined reference to `_imp___ZN12QApplication4execEv'
main.cpp:-1: error: undefined reference to `_imp___ZN12QApplicationD1Ev'
main.cpp:-1: error: undefined reference to `_imp___ZN12QApplicationD1Ev'
:-1: error: release/main.o: bad reloc address 0x13 in section `.eh_frame'
collect2.exe:-1: error: error: ld returned 1 exit status
The errors seem to suggest that one or more of the core Qt libraries cannot be found, however, the .pro file contains the line QT += core gui widgets and there is nothing Debug/Release specific. I've tried cleaning/rebuilding the project and restarting Qt Creator, to no avail. I have no problems compiling Release builds for other projects. I'm using Qt version 5.2.1. Any ideas?
Update:
I've singled out this line in the .pro file as the cause
win32: LIBS += -L"C:/Program Files (x86)/MATLAB/R2015b/bin/win32" -llibmat -llibmx
Inside the makefile I see this
LIBS = -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain "-LC:/Program Files (x86)/MATLAB/R2015b/bin/win32" -llibmat -llibmx -LC:\Qt\Qt5.2.1\5.2.1\mingw48_32\lib -lQt5Widgets -lQt5Gui -lQt5Core
I suspect the problem lies in the order in which the link libraries are listed in the makefile. I vaguely recall encountering a similar problem in the past. How can I force qmake to place the Matlab libraries at the end of the list?

C++ Qt MingW bad reloc 0xc address in section rdata

I'm with Qt 5.5 on Windows 10 64 bit with MingW compiler.
I'm trying to compile my project in debug mode => Works perfectly
But in release mode, I have these errors:
undefined reference to `TileMap::XYToNode(int, int) const'
undefined reference to `TileMap::XYToNode(int, int) const'
./release\perso.o: bad reloc address 0xc in section `.rdata'
collect2.exe:-1: erreur : error: ld returned 1 exit status
I have tried to do clean, qmake, and rebuild, but there are still errors.
I use some SFML dlls, and dlls I created. My TileMap class inherits a SFML class, and a micropather class (which is in one of the dlls).
Yes, I have tried Google before.
The .pro file:
TEMPLATE = app
TARGET = TealDemo
QT = widgets
SOURCES += ........
LIBS += -LC:/Qt/5.5/SFML/lib -LC:/Qt/5.5/micropather/lib -LC:/Qt/5.5/pathstore/lib
CONFIG(release): LIBS += -lsfml-graphics -lsfml-main -lsfml-window -lsfml-system -lmp -lpathstore
CONFIG(debug): LIBS += -lsfml-graphics-d -lsfml-main-d -lsfml-window-d -lsfml-system-d -lmpd -lpathstored
INCLUDEPATH += C:/Qt/5.5/SFML/include C:/Qt/5.5/micropather/include C:/Qt/5.5/pathstore/include
DEPENDPATH += C:/Qt/5.5/SFML/include C:/Qt/5.5/micropather/include C:/Qt/5.5/pathstore/include
HEADERS += .......
CONFIG += C++11 warn_on
debug {
DEFINES += TEAL_DEBUG
}
How to resolve this ?
Thanks
I deleted the inline before the function in the .cpp file, and it worked... Such strange.

Qt - undefined reference to... (Ubuntu 14.04 LTS 64 bits)

I try to compile one of my project I made with windows 7 64 bits using Qt5.3.1 MSVC2012, by using now Qt5.4 gcc 64 bits with Unbuntu 14.04 LTS.
But I have some "undefined reference to" errors :
/home/innocore/Software/CES_2015/trunk/MainProgram/../bin//libSmartphoneController.a(smartphonecontroller.o): In function SmartphoneController::init()':
/home/innocore/Software/CES_2015/trunk/bin/../LibSmartphoneController/smartphonecontroller.cpp:11: undefined reference toRemoteADBInterface::RemoteADBInterface(QString, QString, int, QObject*)'
/home/innocore/Software/CES_2015/trunk/bin/../LibSmartphoneController/smartphonecontroller.cpp:13: undefined reference to RemoteADBInterface::newMessage(RemoteADBInterface::Message const&, QVariant const&)'
/home/innocore/Software/CES_2015/trunk/MainProgram/../bin//libSmartphoneController.a(smartphonecontroller.o): In functionQMetaObject::Connection QObject::connect(QtPrivate::FunctionPointer::Object const*, void (RemoteADBInterface::)(RemoteADBInterface::Message const&, QVariant const&), QtPrivate::FunctionPointer::Object const, void (SmartphoneController::*)(RemoteADBInterface::Message const&, QVariant const&), Qt::ConnectionType)':
/opt/5.4/gcc_64/include/QtCore/qobject.h:239: undefined reference to `RemoteADBInterface::staticMetaObject'
collect2: error: ld returned 1 exit status
my project is composed of one exe and several libraries like libSmartphoneController.a or libRemoteADB.a.
All the libraries compile correctly and are created in the right directory. The problem occurs when I compile my exe program (MainProgram).
In the .pro, I'm sure I include the right dependencies :
unix:!macx {
CONFIG(release, release|debug) {
LIBS += -L$$PWD/../Lib/ -lAudioPlayer -lDisplay -lSWCom -lRemoteADB -lDMS -lTVRemote \
-lHDMIMixer -lSmartphoneController -lRemoteServer
}
CONFIG(debug, release|debug) {
LIBS += -L$$PWD/../bin/ -lAudioPlayer -lDisplay -lSWCom -lRemoteADB -lDMS -lTVRemote \
-lHDMIMixer -lSmartphoneController -lRemoteServer
} }
The lib SmartphoneController also have two dependencies :
in SmartphoneController.pro :
unix:!macx {
CONFIG(release, release|debug) {
LIBS += -L$$PWD/../Lib/ -lRemoteADB -lRemoteServer
}
CONFIG(debug, release|debug) {
LIBS += -L$$PWD/../bin/ -lRemoteADB -lRemoteServer
} }
The problem is that it does not find the definition of some function in the lib RemoteADB (contructor, signal readMessage...). I don't have any problem with all other libs + it compiles perfectly on windows...
Any idea ?
Thanks in advance for your help
I see a possible cause for your problem: the compiler does not find the library file and you can solve this by adding in the .pro file the full path where you have saved the libraries, what I can see here is that you have different path where to search libraries if are compiling debug or release, are you sure you have the correct libraries in both places ?
This would be an example of what to put in your pro file:
LIBS += -L$$OUT_PWD/../../../projects/mylibs/release/

Qt/mingw32 undefined reference errors... unable to link a .lib

I am new to Qt and have one error I am unable to fix.
I have a bunch of windows (VS2005) static library file (.lib). And I am testing if they work well with Qt. So I took the most simple library that I have. (Called MessageBuffer).
So I added MessageBuffer.h to the main.cpp, and added the location of those file in the INCLUDEPATH of the .pro.
Until then everything seem fine, I can use the class and Qt IDE show all method and everything. So to me it look like it found the .h file.
Now I added the MessageBuffer.lib (VS2005/Debug build) in the .pro like this:
LIBS += E:/SharedLibrary/lib/MessageBufferd.lib
I have also tried the following:
win32:LIBS += E:/SharedLibrary/lib/MessageBufferd.lib
LIBS += -LE:/SharedLibrary/lib -lMessageBufferd
win32:LIBS += -LE:/SharedLibrary/lib -lMessageBufferd
Here is the content of my .pro file:
QT += opengl
TARGET = SilverEye
TEMPLATE = app
INCLUDEPATH += E:/SharedLibrary/MessageBuffer
SOURCES += main.cpp \
silvereye.cpp
HEADERS += silvereye.h
FORMS += silvereye.ui
OTHER_FILES +=
win32:LIBS += E:/SharedLibrary/lib/MessageBufferd.lib
They all give me the same errors: (and I get the same even if I don't include the .lib)
Running build steps for project SilverEye...
Configuration unchanged, skipping QMake step.
Starting: C:/Qt/2009.03/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\SilverEye.exe debug/main.o debug/silvereye.o debug/moc_silvereye.o -L"c:\Qt\2009.03\qt\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind E:/SharedLibrary/lib/MessageBufferd.lib -lQtOpenGLd4 -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
mingw32-make: Leaving directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
debug/main.o: In function `Z5qMainiPPc':
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:12: undefined reference to `MessageBuffer::MessageBuffer()'
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:13: undefined reference to `MessageBuffer::Append(char*, int)'
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:17: undefined reference to `MessageBuffer::~MessageBuffer()'
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:17: undefined reference to `MessageBuffer::~MessageBuffer()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\SilverEye.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project SilverEye
When executing build step 'Make'
Can anyone help please?
Based on the question Use libraries compiled with visual studio in an application compiled by g++ (mingw) and the MSDN forum post I can't mix VC & GCC it does not appear you can link a gcc application with visual c++ compiled libraries.
The solution would be to recompile everything with the same compiler.
The MinGW FAQ discusses this problem and offers a solution:
Create a definition file using reimp (for lib files) or pexports (for dll files).
Remove the underscore prefixes from the stdcall functions.
Use dlltool to convert the MSVC library into a MinGW library with the new definition.
That didn’t work. We finally removed the ordinals from the function names, which caused it to compile. But the program wouldn’t run because it couldn’t find the linked functions in the DLL. Finally, after consulting the MSDN documentation for definition files, we changed the build instructions:
Create a definition file using reimp.
For each stdcall function (formatted as _name#ordinal) add a line name = _name#ordinal, allowing MinGW to map its stdcall naming convention to that of MSVC.
Use dlltool to convert the MSVC library into a MinGW library with the new definition.
It worked! To compile the project you must simply:
Download and install the Qt/Windows package, which includes MinGW.
Download reimp and drop it into the MinGW/bin folder.
Download the development packages for the third-party libraries and point an environment variable to that location.
Build the project with the usual qmake/make commands.
Taken from:
http://blog.outofhanwell.com/2006/05/01/linking-msvc-libraries-with-mingw-projects/
I assume that you have used the MessageBuffer library in another application with problems. The error looks like it either cannot find the library or the MessageBuffer class is not being exported.
Have you tried putting -l on front of the library in the pro file?
win32:LIBS += -lE:/SharedLibrary/lib/MessageBufferd.lib
See my other answer. I added the other answer because I didn't want to make this answer any more messy than it already was.
Tried so far:
Not a typo, d is appended to the library
Using the lib extension is correct as seen in the output