Unsolved Undefined reference to qDebug
-
I'm still at beginner's crawling stage ..
but I do spot a space in your path .. /QT Projects/
I've learned to purge all spaces in my projects under development .. e.g. /Qt_Projects/
May not be relevant to your problem but worth remembering. -
@ayush_mistral
Hello,
Getting the same error would mean that your problem shouldn't be related to the library itself, however I second @SGaist's note, you've not provided the linking step, only the errors. I'd suggest finding where the linker runs and allow for us to see what's done at that particular point.Kind regards.
-
Hi,
Regarding the version , I am using version 5.5.1 of Qt and cpp unit version is 1.12.1
Regarding the linking step please find the complete compiler output as mentioned below.11:16:28: Running steps for project cppunittest_gui...
11:16:28: Starting: "/usr/bin/make" clean
rm -f moc_mainwindow.cpp moc_cmTcp.cpp moc_cmUdp.cpp moc_simserver.cpp
rm -f ui_mainwindow.h
rm -f main.o mainwindow.o cmTcp.o cmUdp.o CommunicationModule.o CommunicationModuleTest.o CmTcpTest.o CmUdpTest.o simserver.o moc_mainwindow.o moc_cmTcp.o moc_cmUdp.o moc_simserver.o
rm -f ~ core .core
11:16:28: The process "/usr/bin/make" exited normally.
11:16:28: Configuration unchanged, skipping qmake step.
11:16:28: Starting: "/usr/bin/make"
/home/mistral/Qt/5.5/gcc_64/bin/uic mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o main.o main.cpp
main.cpp: In function 'int main(int, char)':
main.cpp:18:20: warning: ignoring return value of 'int testing::UnitTest::Run()', declared with attribute warn_unused_result [-Wunused-result]
RUN_ALL_TESTS();
^
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o mainwindow.o mainwindow.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o cmTcp.o cmTcp.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o cmUdp.o cmUdp.cpp
cmUdp.cpp: In member function 'CM_EN_RETURN cCmUdp::cmUdpSocketWrite(CM_UDPSOCKET_HANDLE*, SINT8*, quint32)':
cmUdp.cpp:195:12: warning: variable 's32BytesRead' set but not used [-Wunused-but-set-variable]
qint32 s32BytesRead;
^
cmUdp.cpp:219:60: warning: 'ps8RecvBuffer' may be used uninitialized in this function [-Wmaybe-uninitialized]
&clientPort);
^
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o CommunicationModule.o CommunicationModule.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o CommunicationModuleTest.o CommunicationModuleTest.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o CmTcpTest.o CmTcpTest.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o CmUdpTest.o CmUdpTest.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o simserver.o simserver.cpp
/home/mistral/Qt/5.5/gcc_64/bin/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/home/mistral/Qt/5.5/gcc_64/mkspecs/linux-g++ -I'/home/mistral/Desktop/QT Projects/cppunittest_gui' -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I/home/mistral/Qt/5.5/gcc_64/include -I/home/mistral/Qt/5.5/gcc_64/include/QtWidgets -I/home/mistral/Qt/5.5/gcc_64/include/QtGui -I/home/mistral/Qt/5.5/gcc_64/include/QtNetwork -I/home/mistral/Qt/5.5/gcc_64/include/QtCore mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o moc_mainwindow.o moc_mainwindow.cpp
/home/mistral/Qt/5.5/gcc_64/bin/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/home/mistral/Qt/5.5/gcc_64/mkspecs/linux-g++ -I'/home/mistral/Desktop/QT Projects/cppunittest_gui' -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I/home/mistral/Qt/5.5/gcc_64/include -I/home/mistral/Qt/5.5/gcc_64/include/QtWidgets -I/home/mistral/Qt/5.5/gcc_64/include/QtGui -I/home/mistral/Qt/5.5/gcc_64/include/QtNetwork -I/home/mistral/Qt/5.5/gcc_64/include/QtCore cmTcp.h -o moc_cmTcp.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o moc_cmTcp.o moc_cmTcp.cpp
/home/mistral/Qt/5.5/gcc_64/bin/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/home/mistral/Qt/5.5/gcc_64/mkspecs/linux-g++ -I'/home/mistral/Desktop/QT Projects/cppunittest_gui' -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I/home/mistral/Qt/5.5/gcc_64/include -I/home/mistral/Qt/5.5/gcc_64/include/QtWidgets -I/home/mistral/Qt/5.5/gcc_64/include/QtGui -I/home/mistral/Qt/5.5/gcc_64/include/QtNetwork -I/home/mistral/Qt/5.5/gcc_64/include/QtCore cmUdp.h -o moc_cmUdp.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o moc_cmUdp.o moc_cmUdp.cpp
/home/mistral/Qt/5.5/gcc_64/bin/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/home/mistral/Qt/5.5/gcc_64/mkspecs/linux-g++ -I'/home/mistral/Desktop/QT Projects/cppunittest_gui' -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I/home/mistral/Qt/5.5/gcc_64/include -I/home/mistral/Qt/5.5/gcc_64/include/QtWidgets -I/home/mistral/Qt/5.5/gcc_64/include/QtGui -I/home/mistral/Qt/5.5/gcc_64/include/QtNetwork -I/home/mistral/Qt/5.5/gcc_64/include/QtCore simserver.h -o moc_simserver.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/gtest -I/usr/include/cppunit -I/usr/include/cppunit -I../../../Qt/5.5/gcc_64/include -I../../../Qt/5.5/gcc_64/include/QtWidgets -I../../../Qt/5.5/gcc_64/include/QtGui -I../../../Qt/5.5/gcc_64/include/QtNetwork -I../../../Qt/5.5/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.5/gcc_64/mkspecs/linux-g++ -o moc_simserver.o moc_simserver.cpp
g++ -Wl,-rpath,/home/mistral/Qt/5.5/gcc_64 -Wl,-rpath,/home/mistral/Qt/5.5/gcc_64/lib -o cppunittest_gui main.o mainwindow.o cmTcp.o cmUdp.o CommunicationModule.o CommunicationModuleTest.o CmTcpTest.o CmUdpTest.o simserver.o moc_mainwindow.o moc_cmTcp.o moc_cmUdp.o moc_simserver.o -L/home/mistral/Desktop/QT\ Projects/cppunittest_gui/../../../../../usr/lib/ -lgtest -L/home/mistral/Desktop/QT\ Projects/cppunittest_gui/../../../../../usr/lib/x86_64-linux-gnu/ -lcppunit -L/home/mistral/Qt/5.5/gcc_64/lib -lQt5Widgets -L/usr/X11R6/lib64 -L/usr/lib/x86_64-linux-gnu -lQt5Gui -lQt5Network -lQt5Core -lGL -lpthread
cmUdp.o: In functioncCmUdp::cmUdpSocketInit(CM_UDPSOCKET_HANDLE*, HA_UDP_PARAM*)': /home/mistral/Desktop/QT Projects/cppunittest_gui/cmUdp.cpp:73: undefined reference to
QDebug::~QDebug()'
/home/mistral/Desktop/QT Projects/cppunittest_gui/cmUdp.cpp:73: undefined reference toQDebug::~QDebug()' cmUdp.o: In function
cCmUdp::cmUdpSocketRead(CM_UDPSOCKET_HANDLE*, char*, unsigned int)':
/home/mistral/Desktop/QT Projects/cppunittest_gui/cmUdp.cpp:128: undefined reference toQDebug::~QDebug()' /home/mistral/Desktop/QT Projects/cppunittest_gui/cmUdp.cpp:128: undefined reference to
QDebug::~QDebug()'
cmUdp.o: In functioncCmUdp::cmUdpSocketClose(CM_UDPSOCKET_HANDLE*)': /home/mistral/Desktop/QT Projects/cppunittest_gui/cmUdp.cpp:279: undefined reference to
QDebug::~QDebug()'
cmUdp.o:/home/mistral/Desktop/QT Projects/cppunittest_gui/cmUdp.cpp:279: more undefined references to `QDebug::~QDebug()' follow
collect2: error: ld returned 1 exit status
make: *** [cppunittest_gui] Error 1
11:16:45: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project cppunittest_gui (kit: Desktop Qt 5.5.1 GCC 64bit)
When executing step "Make"
11:16:45: Elapsed time: 00:16.Thanks
Ayush -
@ayush_mistral
At a first glance it looks okay, maybe @SGaist will spot something suspicious, I don't see anything out of the ordinary. What do you have herecmUdp.cpp:73
in your source (+- a couple of lines)? In principle the linker shouldn't be complaining about the destructor. Where does your Qt come from, have you built it yourself or you've installed it from the Qt site? Are you sure the compiler/linker used for building Qt matches the one you're using (although it seem you are)?Kind regards.
-
Hi,
I download the QT version for linux from the Qt website only and for compiling and building my application I am using Qt creator IDE.
Thanks and Regards
Ayush -
Did you also installed Qt from your distribution ?
-
@kshegunov you are linking with wrong libraries. You might have installed Qt from your package manager. So its linking with your program since linker is finding that before the actual libraries. If you are using Qt Creator go to projects tab and chanch path variable. Or uninstall Qt installed using your package manager
-
@SGaist just saw your post. I am thinking the same
-
-
I am not getting clearly. I download my qt set up from qt website and use the same script for installation.
Thanks and Regards
Ayush -
Hi,
I didn't install QT from package manager but ran the executable from the set up which I obtained/downloaded from the QT website.
Secondly I am also using Google test framework for testing my project but that is not causing any problem.
I want to know why including cpp unit library and headers in the .pro file is causing the linking error? -
Could you check if you have libQt5*.so in any other place than /home/mistral/Qt/5.5/gcc_64/lib
-
This thread got really confusing.
@asanka424
I'm not linking anything, it's in fact Ayush who's having trouble.@ayush_mistral
Make sure you're running theqmake
that came with the package you installed, and not a system-wide installed one. That's what's @SGaist was implying with his question, however it seems you do indeed./home/mistral/Qt/5.5/gcc_64/bin/uic
this looks exactly as I'd expect. I don't think your problem is related to the cpp unit library as I mentioned before. Besides runningqmake
again to recreate the project I'm running out of ideas ...Kind regards.
-
Hi,
There are some common libQt5*.so files also present in the path /usr/lib/x86_64-linux-gnu
Thanks and Regards
Ayush -
@ayush_mistral
Okay, then this: "Make sure you're running the qmake that came with the package you installed, and not a system-wide installed one." is quite relevant.
Use theqmake
that came with the package you installed. You can find it somewhere in the/home/mistral/Qt/.../bin
folder. You go to your project, runmake clean
, then use the correctqmake
to create theMakefile
anew, and then youmake
your project again.Kind regards.
-
Hi I found the qmake executable in the path Qt5.5/gcc_64/bin folder
Can you please tell me which tab should I change in qt projects tab to provide the path for the appropriate qmake?
-
@ayush_mistral
Actually you set up a kit for QtCreator and then change the kit for your project. To make your kit work with the Qt you've downloaded just specify the correctqmake
executable and a name that you'd recognize.
The kit your project uses is on the projects page, up-most, just below the name of the project. You have the kit name there and under it two buttons - build and run. Pointing at the kit name ("Qt 5.6 64 bit" in my case) will cause a down arrow to show next to the text. Clicking the arrow there's a context menu that has Change kit on it, and you just select the one you like. After changing the kit, do a full rebuild of your project.Kind regards.
-
Hi,
I have the following settings in the newly created kit
Name- cppunit_qt
Device type - desktop
Device - Local PC
Compiler - GCC (x86 64bit in /usr/bin)
Debugger - System GDB at /usr/bin/gdbTry to make clean and rebuild the project still the error is the same
Can you please tell me if I am missing something or doing something wrong?Thanks and Regards
Ayush
Qt Version - Qt5.5.1GCC 64bit -
@ayush_mistral Which Qt version did you set in that kit?
-
I set 5.5.1