Results 1 to 3 of 3

Thread: My application links against both qt4 and qt5 libs

  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default My application links against both qt4 and qt5 libs

    Hi, I'm porting my application from qt4 to qt5. I filled my CMakeLists.txt of if/else conditions to handle qt5 (default) and qt4 (minimum) requirements. During compilation I fixed all error messages and seems all ok. But when I try to launch it, seg-fault occurs and the debugger opens disassembler on a line of /usr/lib/libQtGui.so.4, and this is strange since the application should build against qt5. I used ldd on the executable and I found a mixture of qt4/qt5 libraries:

    $ ldd ./myapp
    linux-vdso.so.1 (0x00007f21147ae000)
    libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0x00007f2113f2c000)
    libQt5Widgets.so.5 => /usr/lib/libQt5Widgets.so.5 (0x00007f2113749000)
    libQt5Network.so.5 => /usr/lib/libQt5Network.so.5 (0x00007f2113411000)
    libQt5Xml.so.5 => /usr/lib/libQt5Xml.so.5 (0x00007f21131d7000)
    libQt5Svg.so.5 => /usr/lib/libQt5Svg.so.5 (0x00007f2112f8b000)
    libphonon.so.4 => /usr/lib/libphonon.so.4 (0x00007f2112d1b000)
    libQtSvg.so.4 => /usr/lib/libQtSvg.so.4 (0x00007f2112ac5000)
    libqjson.so.0 => /usr/lib/libqjson.so.0 (0x00007f211289e000)
    libQtXml.so.4 => /usr/lib/libQtXml.so.4 (0x00007f211265c000)
    libQt5Gui.so.5 => /usr/lib/libQt5Gui.so.5 (0x00007f211203d000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f2111d39000)
    libm.so.6 => /lib/libm.so.6 (0x00007f2111a36000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f2111820000)
    libc.so.6 => /lib/libc.so.6 (0x00007f2111475000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007f2111257000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007f2111042000)
    libicui18n.so.51 => /usr/lib/libicui18n.so.51 (0x00007f2110c3f000)
    libicuuc.so.51 => /usr/lib/libicuuc.so.51 (0x00007f21108c8000)
    libdl.so.2 => /lib/libdl.so.2 (0x00007f21106c4000)
    librt.so.1 => /lib/librt.so.1 (0x00007f21104bc000)
    libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007f21101c7000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f2114591000)
    libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f210fe90000)
    libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007f210fc26000)
    libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007f210f81e000)
    libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007f210f33e000)
    libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0x00007f210e6bd000)
    libQtDBus.so.4 => /usr/lib/libQtDBus.so.4 (0x00007f210e442000)
    libpulse.so.0 => /usr/lib/libpulse.so.0 (0x00007f210e1f8000)
    libpulse-mainloop-glib.so.0 => /usr/lib/libpulse-mainloop-glib.so.0 (0x00007f210dff4000)
    libqzeitgeist.so.1 => /usr/lib/libqzeitgeist.so.1 (0x00007f210ddd0000)
    libpng16.so.16 => /usr/lib/libpng16.so.16 (0x00007f210db9c000)
    libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f210d86e000)
    libicudata.so.51 => /usr/lib/libicudata.so.51 (0x00007f210c124000)
    libpcre.so.0 => /usr/lib/libpcre.so.0 (0x00007f210becb000)
    libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f210bcae000)
    libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007f210ba0f000)
    libSM.so.6 => /usr/lib/libSM.so.6 (0x00007f210b808000)
    libICE.so.6 => /usr/lib/libICE.so.6 (0x00007f210b5ed000)
    libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00007f210b3e3000)
    libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x00007f210b1d9000)
    libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x00007f210af9f000)
    libXext.so.6 => /usr/lib/libXext.so.6 (0x00007f210ad8e000)
    libdbus-1.so.3 => /usr/lib/libdbus-1.so.3 (0x00007f210ab48000)
    libjson-c.so.2 => /usr/lib/libjson-c.so.2 (0x00007f210a93e000)
    libpulsecommon-4.0.so => /usr/lib/pulseaudio/libpulsecommon-4.0.so (0x00007f210a6d2000)
    libnvidia-tls.so.319.49 => /usr/lib/libnvidia-tls.so.319.49 (0x00007f210a4cf000)
    libnvidia-glcore.so.319.49 => /usr/lib/libnvidia-glcore.so.319.49 (0x00007f2107f77000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f2107d74000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f2107b6f000)
    libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007f210795f000)
    libuuid.so.1 => /usr/lib/libuuid.so.1 (0x00007f210775b000)
    libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x00007f2107555000)
    libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007f210732d000)
    libsndfile.so.1 => /usr/lib/libsndfile.so.1 (0x00007f21070c6000)
    libasyncns.so.0 => /usr/lib/libasyncns.so.0 (0x00007f2106ec1000)
    libFLAC.so.8 => /usr/lib/libFLAC.so.8 (0x00007f2106c90000)
    libvorbisenc.so.2 => /usr/lib/libvorbisenc.so.2 (0x00007f21067c2000)
    libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0x00007f2106596000)
    libogg.so.0 => /usr/lib/libogg.so.0 (0x00007f2106390000)
    libnsl.so.1 => /lib/libnsl.so.1 (0x00007f2106178000)
    libresolv.so.2 => /lib/libresolv.so.2 (0x00007f2105f61000)
    Unfortunately I can't remove qt4 since required by KDE. This is an excerpt of CMakeLists.txt I'm using:

    Qt Code:
    1. ...
    2. cmake_minimum_required(VERSION 2.6)
    3.  
    4. set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
    5.  
    6. find_package(Qt5Core)
    7. if( Qt5Core_DIR )
    8. message(STATUS "Found Qt5! Be aware that Qt5-support is still experimental and not officially supported!")
    9. ADD_DEFINITIONS(-fPIC)
    10. find_package(Qt5Widgets REQUIRED)
    11. find_package(Qt5Gui REQUIRED)
    12. find_package(Qt5Network REQUIRED)
    13. find_package(Qt5Xml REQUIRED)
    14. find_package(Qt5Svg REQUIRED)
    15. find_package(Qt5LinguistTools REQUIRED)
    16. set(CMAKE_AUTOMOC ON)
    17. endif()
    18. if( NOT Qt5Core_DIR )
    19. find_package(Qt4 COMPONENTS QTCORE QTGUI QTNETWORK QTSVG QTXML)
    20. endif()
    21. find_package(Phonon REQUIRED)
    22. find_package(QJson REQUIRED)
    23.  
    24. # Handle Translations
    25. file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/myapp_*.ts)
    26. set(TRANSLATIONS ${TRANS_FILES})
    27.  
    28. ...
    29.  
    30. if( Qt5Core_DIR )
    31. include_directories(${Qt5Core_INCLUDE_DIRS}
    32. ${Qt5Widgets_INCLUDE_DIRS}
    33. ${Qt5Network_INCLUDE_DIRS}
    34. ${Qt5Xml_INCLUDE_DIRS}
    35. ${Qt5Svg_INCLUDE_DIRS}
    36. ${PHONON_INCLUDES}
    37. ${QJSON_INCLUDE_DIR}
    38. ${CMAKE_CURRENT_BINARY_DIR}
    39. ${CMAKE_CURRENT_SOURCE_DIR})
    40.  
    41. qt5_add_resources(myapp_RC_SRCS ${myapp_RCS} )
    42. qt5_wrap_ui(myapp_UI_HEADERS ${myapp_UI})
    43. qt5_add_translation(myapp_I18N ${TRANSLATIONS})
    44. endif()
    45. if( NOT Qt5Core_DIR )
    46. include_directories(${QT_INCLUDES}
    47. ${PHONON_INCLUDES}
    48. ${QJSON_INCLUDE_DIR}
    49. ${CMAKE_CURRENT_BINARY_DIR}
    50. ${CMAKE_CURRENT_SOURCE_DIR})
    51. qt4_add_resources(myapp_RC_SRCS ${myapp_RCS} )
    52. qt4_wrap_ui(myapp_UI_HEADERS ${myapp_UI})
    53. qt4_automoc(${myapp_SRCS})
    54. qt4_add_translation(myapp_I18N ${TRANSLATIONS})
    55. endif()
    56.  
    57. add_executable(myapp main.cpp ${myapp_SRCS} ${myapp_RC_SRCS} ${myapp_UI_HEADERS} ${myapp_I18N})
    58.  
    59. if( Qt5Core_DIR )
    60. target_link_libraries(myapp
    61. ${Qt5Core_LIBRARIES}
    62. ${Qt5Widgets_LIBRARIES}
    63. ${Qt5Network_LIBRARIES}
    64. ${Qt5Xml_LIBRARIES}
    65. ${Qt5Svg_LIBRARIES}
    66. ${PHONON_LIBRARY}
    67. ${QT_QTSVG_LIBRARY}
    68. ${QJSON_LIBRARY}
    69. ${QT_QTXML_LIBRARY})
    70. endif()
    71. if( NOT Qt5Core_DIR )
    72. target_link_libraries(myapp
    73. ${QT_QTCORE_LIBRARY}
    74. ${QT_QTGUI_LIBRARY}
    75. ${QT_QTNETWORK_LIBRARY}
    76. ${PHONON_LIBRARY}
    77. ${QT_QTSVG_LIBRARY}
    78. ${QJSON_LIBRARY}
    79. ${QT_QTXML_LIBRARY})
    80. endif()
    To copy to clipboard, switch view to plain text mode 

    Any idea about the problem?

    Very thanks.
    Giuseppe CalÃ

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: My application links against both qt4 and qt5 libs

    I cannot see that KDE has anything to do with this: you are not linking to any KDE library in the snippet you show.
    Chances are that the phonon and QJson libraries you have asked CMake to find and link have been built with Qt4. Build and link to Qt5 versions or use the Qt5 equivalents.
    Last edited by ChrisW67; 22nd December 2013 at 22:32.

  3. #3
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: My application links against both qt4 and qt5 libs

    Quote Originally Posted by ChrisW67 View Post
    I cannot see that KDE has anything to do with this: you are not linking to any KDE library in the snippet you show.
    My intention was to remove qt4 and leave only qt5 stuff and see if it compiled correctly.

    Quote Originally Posted by ChrisW67 View Post
    Chances are that the phonon and QJson libraries you have asked CMake to find and link have been built with Qt4. Build and link to Qt5 versions or use the Qt5 equivalents.
    This should be the real problem. I already compiled phonon4qt5. For QJson I read that Qt5 has native support for json, so no need of external library. But I'm stuck converting QVariantMap in json QByteArray (I can't find something like QJson::Serializer)...

    EDIT: Never mind. Found right way

    Thanks for your help
    Last edited by jiveaxe; 23rd December 2013 at 10:54.
    Giuseppe CalÃ

Similar Threads

  1. Replies: 1
    Last Post: 14th March 2013, 15:38
  2. building a static lib with links to other static libs
    By hubipet in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2011, 19:13
  3. Replies: 1
    Last Post: 13th November 2009, 19:40
  4. Need Links fot QT4.2.3
    By nirup in forum Qt Tools
    Replies: 1
    Last Post: 14th May 2007, 11:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.