Trying to implement QChart, get error undefined reference to 'qt_version_tag@Qt_5.9'
-
I am running Qt 5.9.1 on Ubuntu 16.04. I have successfully built and run the linechart example.
When I start trying to migrate code from linechart to my application, I get the following link error:
undefined reference to 'qt_version_tag@Qt_5.9', associated with libQt5Charts.soI understand that this is usually due to issues with linking to the wrong version of a library but I am at a loss to see what I'm doing wrong.
I've checked which libraries the linechart example is using:
$ ldd linechart | grep -i libQt5
libQt5Charts.so.5 => /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Charts.so.5 (0x00007fd9d140b000)I've checked which libraries my app is using (apart from libQt5Charts.so.5):
$ ldd LTSD | grep -i libQt5
libQt5Widgets.so.5 => /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Widgets.so.5 (0x00007f2451f3d000)
libQt5Gui.so.5 => /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Gui.so.5 (0x00007f245178f000)
libQt5Core.so.5 => /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Core.so.5 (0x00007f2451055000)As soon as I add the line " QChart *slagchart = new QChart();" to my code, I get the error. The linker doesn't build an executable so I can't check ldd to see where it is trying to get the library.
I've tried adding "DEFINES += QT_NO_VERSION_TAGGING" to the .pro file and it seems to make no difference.
-
Build your app without QtCharts and take a look which Qt libraries are used with the help of ldd
-
@markd said in Trying to implement QChart, get error undefined reference to 'qt_version_tag@Qt_5.9':
As noted above, if I comment out the 'new QChart(); line I get the following:
$ ldd LTSD | grep -i libQt5
libQt5Widgets.so.5 => /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Widgets.so.5 (0x00007f2451f3d000)
libQt5Gui.so.5 => /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Gui.so.5 (0x00007f245178f000)
libQt5Core.so.5 => /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Core.so.5 (0x00007f2451055000As soon as I add the line " QChart *slagchart = new QChart();" to my code, I get the error. The linker doesn't build an executable so I can't check ldd to see where it is trying to get the library.
-
@jsulm below is the link output from Qt Creator. You can see "-L/opt/Qt5.9.1/5.9.1/gcc_64/lib -lQt5Charts -lQt5Widgets -lQt5Gui -lQt5Core" down near the bottom.
g++ -Wl,-rpath,/opt/Qt5.9.1/5.9.1/gcc_64/lib -o LTSD LTSDView.o LTVrecord.o LTSlagDetect.o main.o keylok.o GUI_Indicators.o SpinCamera.o imageviewer.o logikaImaging.o qrc_resources.o moc_LTSDView.o moc_LTVrecord.o moc_LTSlagDetect.o moc_GUI_Indicators.o moc_SpinCamera.o moc_imageviewer.o moc_logikaImaging.o -L/usr/local/cuda-8.0/lib64/ -L/usr/lib -lSpinnaker ../LogikaLibrary/libkfunc64.a -Wl,-rpath,/usr/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu/libudev.so.1 -L/usr/local/lib -lopencv_cudabgsegm -lopencv_shape -lopencv_stitching -lopencv_cudastereo -lopencv_videostab -lopencv_superres -lopencv_cudafeatures2d -lopencv_dnn -lopencv_cudacodec -lopencv_ml -lopencv_cudaoptflow -lopencv_cudaobjdetect -lopencv_cudalegacy -lopencv_cudawarping -lopencv_video -lopencv_objdetect -lopencv_photo -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_cudaarithm -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc -lopencv_flann -lopencv_core -lopencv_cudev -L/usr/local/cuda-8.0/lib64 -lcuda -lcudart -L/opt/Qt5.9.1/5.9.1/gcc_64/lib -lQt5Charts -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Charts.so: undefined reference to `qt_version_tag@Qt_5.9' /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Charts.so: undefined reference to `operator delete(void*, unsigned long)@Qt_5' Makefile:288: recipe for target 'LTSD' failed collect2: error: ld returned 1 exit status make: *** [LTSD] Error 1 16:07:11: The process "/usr/bin/make" exited with code 2. Error while building/deploying project LTSD (kit: Desktop Qt 5.9.1 GCC 64bit) When executing step "Make"
As far as I can see, everything is pointing to opt/Qt5.9.1/...
I've added "DEFINES += QT_NO_VERSION_TAGGING" to the .pro file, which as I understand it, is supposed to suppress the version tagging test at link time but I still get the same error.
-
This is really strange. Can you check if the libraries have the same qt_version_tags with 'nm' ?
nm /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Charts.so.5 | grep qt_version_tag
nm /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Widgets.so.5 | grep qt_version_tagDid you build Qt 5.9.1 by your own?
-
@Christian-Ehrlicher I used the pre-built distribution
qt-opensource-linux-x64-5.9.1.run
output from the nm command is as follows:
mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$ nm libQt5Charts.so.5 nm: libQt5Charts.so.5: no symbols mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$ nm libQt5Widgets.so.5 nm: libQt5Widgets.so.5: no symbols
I'm guessing that isn't what you expected to see but I don't know enough about linux or Qt to know what it means.
-
@markd , @Christian-Ehrlicher
I needed to do this the other day, but didn't know how to discover embedded Qt version, as recommended by Christian.So that he knows, like you I find
nm
reports "no symbols", sincefile libQt5Widgets.so.5
tells you it's "stripped".On a whim, I just tried
objdump -T -t /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.12.2 | grep -i qt_version_tag
and I do get:
0000000000000000 DO *UND* 0000000000000000 Qt_5.12 qt_version_tag
@Christian-Ehrlicher
Is that5.12
all you expected fromnm
, or should it be more specific like5.12.2
? -
@Christian-Ehrlicher
I tried objdump and got the following:mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$ objdump -T -t libQt5Charts.so.5 | grep -i qt_version_tag 0000000000000000 DO *UND* 0000000000000000 Qt_5.9 qt_version_tag
-
And what's the output for the other libs in there like e.g. QtCore?
-
mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$ objdump -T -t libQt5Core.so.5 | grep -i qt_version_tag 000000000035aa9d g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_0 000000000035aa9c g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_1 000000000035aa9b g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_2 000000000035aa9a g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_3 000000000035aa99 g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_4 000000000035aa98 g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_5 000000000035aa97 g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_6 000000000035aa96 g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_7 000000000035aa95 g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_8 000000000035aa94 g DO .rodata 0000000000000001 Qt_5 qt_version_tag_5_9 000000000035aa97 g DO .rodata 0000000000000001 (Qt_5.6) qt_version_tag 000000000035aa94 g DO .rodata 0000000000000001 Qt_5.9 qt_version_tag 000000000035aa9c g DO .rodata 0000000000000001 (Qt_5.1) qt_version_tag 000000000035aa95 g DO .rodata 0000000000000001 (Qt_5.8) qt_version_tag 000000000035aa9d g DO .rodata 0000000000000001 (Qt_5.0) qt_version_tag 000000000035aa9a g DO .rodata 0000000000000001 (Qt_5.3) qt_version_tag 000000000035aa9b g DO .rodata 0000000000000001 (Qt_5.2) qt_version_tag 000000000035aa98 g DO .rodata 0000000000000001 (Qt_5.5) qt_version_tag 000000000035aa99 g DO .rodata 0000000000000001 (Qt_5.4) qt_version_tag 000000000035aa96 g DO .rodata 0000000000000001 (Qt_5.7) qt_version_tag mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$ objdump -T -t libQt5Widgets.so.5 | grep -i qt_version_tag 0000000000000000 DO *UND* 0000000000000000 Qt_5.9 qt_version_tag mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$ objdump -T -t libQt5Gui.so.5 | grep -i qt_version_tag 0000000000000000 DO *UND* 0000000000000000 Qt_5.9 qt_version_tag mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$ objdump -T -t libQt5Charts.so.5 | grep -i qt_version_tag 0000000000000000 DO *UND* 0000000000000000 Qt_5.9 qt_version_tag mark@mark:/opt/Qt5.9.1/5.9.1/gcc_64/lib$