简体   繁体   中英

application is linking with both qt5 and qt4

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM