1
votes

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

1
Sometimes the order of libraries in gcc affects the compilation. I don't know if this is the problem here, but just so you know. - user4516901
Interesting, how can you force another order ? I just have to change the dependency order in .pro files ? - palador
That's right. I'm not sure that's the problem here, but in the past I had some similar problems, and changing the order solved it. You might need to add the dependant libraries before dependencies. - user4516901
Well the problem was actually something like that ! I had to put the "sub-dependant" lib AFTER the dependent lib in the mainProgram.pro file. I'm goint to edit my question to show you. Thanks a lot ! - palador

1 Answers

0
votes

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/