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

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/

Related

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.

Errors while linking in Qt5 with poppler

/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)

Undefined reference for external library (C++, QT, Ubuntu 14, CCV)

I'm trying to run the CCV library linked at http://libccv.org/ in QT Creator on Ubuntu 14. I followed this tutorial http://libccv.org/tutorial/ and I'm trying now to run the first simple example. I get these errors:
error: undefined reference to ccv_read_impl(void const*, ccv_dense_matrix_t**, int, int, int, int)
error: undefined reference to ccv_write(ccv_dense_matrix_t*, char*, int*, int, void*)
This is the .pro file of the project:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
unix:!macx: LIBS += -L$$PWD/../../../CNN/ccv/lib/ -lccv
INCLUDEPATH += $$PWD/../../../CNN/ccv/lib
DEPENDPATH += $$PWD/../../../CNN/ccv/lib
unix:!macx: PRE_TARGETDEPS += $$PWD/../../../CNN/ccv/lib/libccv.a
Finally this is the command generated by QT in the compile output:
g++ -m64 -o ccv1 main.o -L/home/fabri/QT/CCV1/ccv1/../../../CNN/ccv/lib/ -lccv
I suppose it's a compiler problem but I don't know what. Thank you.
Modify the example and try to include it like this:
extern "C" {
#include "ccv.h"
}

Boost_program_option linker error even "boost_program_options" exist

I have defined boost_program_options in qmake file .
> CONFIG(debug, debug|release) {
> LIBS += -L"C:\boost_1_55_0\stage\lib" -lboost_program_options-mgw48-mt-d-1_55 -lboost_system-mgw48-mt-d-1_55 -lboost_thread-mgw48-mt-d-1_55 }
CONFIG(release, debug|release) {
> LIBS += -L"C:\boost_1_55_0\stage\lib" -lboost_program_options-mgw48-mt-1_55 -lboost_system-mgw48-mt-1_55 -lboost_thread-mgw48-mt-1_55 }
I want to use a library which called mlpack . And compiled it with the help of mingw.
When I add
"#include <mlpack/core.hpp>"
I am having tones of linker errors( I am pasting a few for ease of read. ):
C:/Qt/Tools/QtCreator/bin/aubioSecond/libs//libmlpack.a(cli.cpp.obj):cli.cpp:(.text+0x3ed): undefined reference to `boost::program_options::options_description::m_default_line_length'
C:/Qt/Tools/QtCreator/bin/aubioSecond/libs//libmlpack.a(cli.cpp.obj):cli.cpp:(.text+0x41e): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
C:/Qt/Tools/QtCreator/bin/aubioSecond/libs//libmlpack.a(cli.cpp.obj):cli.cpp:(.text+0x43b): undefined reference to `boost::program_options::variables_map::variables_map()'
C:/Qt/Tools/QtCreator/bin/aubioSecond/libs//libmlpack.a(cli.cpp.obj):cli.cpp:(.text+0x486a): undefined reference to `boost::program_options::notify(boost::program_options::variables_map&)'
c:/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe:
C:/Qt/Tools/QtCreator/bin/aubioSecond/libs//libmlpack.a(cli.cpp.obj): bad reloc address 0x2 in section `.text$_ZN5boost16exception_detail10clone_baseD1Ev[__ZN5boost16exception_detail10clone_baseD1Ev]'
If anyone has a idea why I am having this problem I will be very thankfull.
Regards
Gilles Barges reports on the mlpack mailing list that the linking error with boost_program_options can be resolved by modifying CMakeLists.txt, line 189, commenting out the bit
set(Boost_LIBRARIES "")
See the mailing list post for more information:
https://mailman.cc.gatech.edu/pipermail/mlpack/2014-August/000488.html