1

I created a simple c++ library. Running ldd give

ldd libTESTPlugin.so.1.0.0 | grep -i qt
    libQt5Widgets.so.5 => /lib64/libQt5Widgets.so.5 (0x00007f5345f14000)
    libQt5Gui.so.5 => /lib64/libQt5Gui.so.5 (0x00007f5345a71000)
    libQt5Core.so.5 => /lib64/libQt5Core.so.5 (0x00007f53455e7000)
    libQtXml.so.4 => /lib64/libQtXml.so.4 (0x00007f5344074000)
    libQtCore.so.4 => /lib64/libQtCore.so.4 (0x00007f5343b71000)
    libQtGui.so.4 => /lib64/libQtGui.so.4 (0x00007f5342e4b000)
    libQtNetwork.so.4 => /lib64/libQtNetwork.so.4 (0x00007f5342afa000)
    libQtSvg.so.4 => /lib64/libQtSvg.so.4 (0x00007f53428a0000)
    libQtWebKit.so.4 => /lib64/libQtWebKit.so.4 (0x00007f53403b3000)
    libQtSql.so.4 => /lib64/libQtSql.so.4 (0x00007f5340170000)
    libQtLocation.so.1 => /lib64/libQtLocation.so.1 (0x00007f5336a09000)
    libQtSensors.so.1 => /lib64/libQtSensors.so.1 (0x00007f53367d5000)
    libQtOpenGL.so.4 => /lib64/libQtOpenGL.so.4 (0x00007f5334ccb000)
    libQtDeclarative.so.4 => /lib64/libQtDeclarative.so.4 (0x00007f5329d06000)
    libQtScript.so.4 => /lib64/libQtScript.so.4 (0x00007f5329845000)
    libQtXmlPatterns.so.4 => /lib64/libQtXmlPatterns.so.4 (0x00007f53291c0000)

so my lib is linked with both qt4 and qt5. It is giving me some integration issue with one other software which is linked with only qt5.

Is there a way to specify the linking only with Qt5 and NOT with Qt4?

P. Preet
  • 15
  • 6
  • 1
    How do you build your library (ide, project settings)? Which linux distro it is and how Qt was installed (some of them comes bundled with older Qt4 version)? What is output of: `qmake --version`? – Dmitriy Apr 18 '17 at 08:50
  • hello Dmitriy. I m using fedora25. Output of qmake --version is QMake version 2.01a Using Qt version 4.8.7 in /usr/lib64 but i have both qmake-qt4 and qmake-qt5 executables in /usr/bin. – P. Preet Apr 19 '17 at 09:33

2 Answers2

0

Try to set Qt5 as default qt version using QT_SELECT environment variable:

export QT_SELECT = <Qt version>

For example:

export QT_SELECT = qt5

Also, if you are using Qt Creator, check again your build configuration.

PS: I am not sure if they still include qtchooser, but you can try to run this command to list all installed versions on your system:

qtchooser -list-versions

Dmitriy
  • 515
  • 7
  • 14
  • Thanks for the prompt reply. I m using QtCreator and build configuration seems to be using qt5. Effective qmake call shows "qmake-qt5 /home/pp/QGis/code/TESTPlugin/TESTPlugin.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug && /usr/bin/make qmake_all" – P. Preet Apr 19 '17 at 09:41
0

Maybe you link with another lib also using Qt, like for example QWT. If you choose the wrong version of such lib it might load the wrong versions of dynamic Qt libs.

See https://stackoverflow.com/a/51282459/1328780 for a solution in case of QWT.

bjhend
  • 1,538
  • 11
  • 25