palador
palador

Reputation: 283

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

Upvotes: 1

Views: 1525

Answers (1)

Marco
Marco

Reputation: 2020

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/

Upvotes: 0

Related Questions