Results 1 to 10 of 10

Thread: Qt 5 linux deployment - using qt.conf for dynamic linking

  1. #1
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Qt 5 linux deployment - using qt.conf for dynamic linking

    I have a Qt 5 app that I don't want to opensource (so I don't want to do a static build of Qt 5 from source). I'm trying to dynamic link the required dependencies using the ldd command, and a qt.conf file in the same folder as the executable. Is this possible? I really would rather not do a static build of Qt 5 and opensource my app. I would like to offer my app as a tar.gz (with dependencies). Here's what I have in my qt.conf:

    [Paths]
    PrefixPath = data
    LibrariesPath = libs_32
    TranslationsPath = translations

    And my folder looks like this:

    Executable
    qt.conf
    data/libs_32/
    data/translations/
    platforms/

    libs_32 contains the dependencies listed by the ldd command. Also, do I need translations?

    The above configuration doesn't work. It only works with Qt 5 installed, which means it's looking for some hard-coded paths I'm missing or configuring incorrectly. Am I missing something or doing something wrong? Any input would greatly be appreciated. Thanks in advance.

  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: Qt 5 linux deployment - using qt.conf for dynamic linking

    You do not need qt.conf to deploy using dynamic linking (it cannot be read until after QtCore loads anyway). Place the Qt libraries in the same folder as the program executable, the plugins in the relevant subfolder (sqldrivers, platform, imageformats etc.). On Windows that is sufficient, and on Linux you need a wrapper script as described in the deployment docs.
    http://qt-project.org/doc/qt-5.0/qtd...t-windows.html
    http://qt-project.org/doc/qt-5.0/qtd...yment-x11.html

  3. #3
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt 5 linux deployment - using qt.conf for dynamic linking

    I used the wrapper script. It didn't work. In my app folder I have:

    myapp
    myapp.sh
    all dependencies fromm the ldd command
    platforms/

    Any ideas?


    Added after 1 6 minutes:


    The Qt libraries needed (libicuxxx, libQt5Corexxx, libQt5Guixxx, libQt5WidgetsXXX) are listed in the Qt 5 library as links to other versions of those files. Maybe resolving the dependencies is having a problem with that.
    Last edited by te777; 31st March 2013 at 01:39.

  4. #4
    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: Qt 5 linux deployment - using qt.conf for dynamic linking

    The links in the installed Qt library typically look like this:
    Qt Code:
    1. # These links all point to a real file
    2. /usr/lib64/qt4/libQtGui.so -> libQtGui.so.4.8.4
    3. /usr/lib64/qt4/libQtGui.so.4 -> libQtGui.so.4.8.4
    4. /usr/lib64/qt4/libQtGui.so.4.8 -> libQtGui.so.4.8.4
    5. # This is the real file
    6. /usr/lib64/qt4/libQtGui.so.4.8.4
    To copy to clipboard, switch view to plain text mode 
    The application will be linked to a major Qt version, e.g. 4, and the linker will be instructed to look for libQtGui.so.4 (or 5). So you can either copy the real file as libQtGui.so.4, or copy libQtGui.so.4.8.4 as-is and also create libQtGui.so.4 as a symbolic link to it. The first approach is less verbose, the second more descriptive of exactly what Qt version is involved but limited to file systems that can maintain the symlink. The LD_LIBRARY_PATH set by the wrapper script ensures the copies on the local folder are found where they normally would not be.
    Last edited by ChrisW67; 31st March 2013 at 09:34.

  5. #5
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt 5 linux deployment - using qt.conf for dynamic linking

    I tried both ways already. There seems to be a problem with dynamic linking with Qt 5. Do you have any Qt 4 apps you can build in Qt 5 try dynamic linking with it? I'll see if I can try building my app in Qt 4 and try the dynamic linking with it.


    Added after 1 51 minutes:


    I did a build in Qt 4.8.2 (installed from software manager in Linux Mint 14 32 bit) and everything works perfectly. I even used a qt.conf setup and that works too (not all those dependencies in the same folder as the executable). There's definitely a problem with dynamic linking with Qt 5. Thanks for the help. Much appreciated.
    Last edited by te777; 31st March 2013 at 11:29.

  6. #6
    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: Qt 5 linux deployment - using qt.conf for dynamic linking

    There's definitely no problem with dynamic linking in Qt5.
    main.cpp:
    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7. w.resize(640, 480);
    8. w.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    test.sh straight from the docs:
    Qt Code:
    1. #!/bin/sh
    2. appname=`basename $0 | sed s,\.sh$,,`
    3.  
    4. dirname=`dirname $0`
    5. tmp="${dirname#?}"
    6.  
    7. if [ "${dirname%$tmp}" != "/" ]; then
    8. dirname=$PWD/$dirname
    9. fi
    10. LD_LIBRARY_PATH=$dirname
    11. export LD_LIBRARY_PATH
    12. $dirname/$appname "$@"
    To copy to clipboard, switch view to plain text mode 
    Deployed files
    Qt Code:
    1. ./test
    2. ./test.sh
    3. ./libQt5Core.so.5 # required by test
    4. ./libQt5Gui.so.5 # required by test
    5. ./libQt5Widgets.so.5 # required by test
    6. ./libQt5DBus.so.5 # required by platform plugin
    7. ./libicuuc.so.49 # required by Qt5Core
    8. ./libicudata.so.49 # required by Qt5Core
    9. ./libicui18n.so.49 # required by Qt5Core
    10. ./platforms
    11. ./platforms/libqxcb.so # required for X11 on Linux
    To copy to clipboard, switch view to plain text mode 
    Check that it won't run without wrapper:
    Qt Code:
    1. $ ./test
    2. ./test: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
    3. $ ldd test
    4. linux-vdso.so.1 (0x00007fff7b3ff000)
    5. libQt5Widgets.so.5 => not found
    6. libQt5Gui.so.5 => not found
    7. libQt5Core.so.5 => not found
    8. libGL.so.1 => /usr/lib64/libGL.so.1 (0x00007fe8428c1000)
    9. libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe8426a4000)
    10. libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/libstdc++.so.6 (0x00007fe8423a0000)
    11. libm.so.6 => /lib64/libm.so.6 (0x00007fe8420aa000)
    12. libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/libgcc_s.so.1 (0x00007fe841e94000)
    13. libc.so.6 => /lib64/libc.so.6 (0x00007fe841aea000)
    14. libnvidia-tls.so.313.26 => /usr/lib64/libnvidia-tls.so.313.26 (0x00007fe8418e7000)
    15. libnvidia-glcore.so.313.26 => /usr/lib64/libnvidia-glcore.so.313.26 (0x00007fe83f3e4000)
    16. libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007fe83f0a5000)
    17. libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007fe83ee93000)
    18. libdl.so.2 => /lib64/libdl.so.2 (0x00007fe83ec8e000)
    19. /lib64/ld-linux-x86-64.so.2 (0x00007fe842be4000)
    20. libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fe83ea6d000)
    21. libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fe83e869000)
    22. libXdmcp.so.6 => /usr/lib64/libXdmcp.so.6 (0x00007fe83e663000)
    To copy to clipboard, switch view to plain text mode 
    Run it with the wrapper:
    Qt Code:
    1. ./test.sh
    To copy to clipboard, switch view to plain text mode 
    Starts no problem.

  7. #7
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt 5 linux deployment - using qt.conf for dynamic linking

    I was missing libQt5DBus. I didn't know I needed it thanks. Works now.

  8. #8
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt 5 linux deployment - using qt.conf for dynamic linking

    ChrisW67, do you know to use qt.conf with a Qt 5 developed application. I can get qt.conf to work with a Qt 4.8.2 developed app, but not Qt 5.0.1

    Here's my qt.conf:

    [Paths]
    Libraries = libs

    Here's my app folder:

    myapp
    libs/
    platforms/
    qt.conf

    The dependencies are in the libs folder. I know you already provided me a solution with a shell file, bit I'd like to know how to use a qt.conf file with a Qt 5 developed app. And thanks a lot for your help. I really appreciate it.

  9. #9
    Join Date
    May 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt 5 linux deployment - using qt.conf for dynamic linking

    Have tried exactly the same approach, but get next error, when trying to launch shell script:

    ./test: symbol lookup error: /home/user/test/./libQt5Widgets.so.5: undefined symbol: _ZTI15QGuiApplication

    How fix it?

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5 linux deployment - using qt.conf for dynamic linking

    Do you have the QtGui library?

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 18th April 2012, 21:01
  2. qt.conf is not loading plugins on linux and Mac
    By yuvaraj.addu in forum Qt Programming
    Replies: 5
    Last Post: 20th January 2012, 19:50
  3. MAC OSX Dynamic Linking and Deployment
    By rokkamraja in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2009, 16:14
  4. MAC OSX Dynamic Linking and Deployment
    By rokkamraja in forum Newbie
    Replies: 0
    Last Post: 23rd October 2009, 13:12
  5. Trolltech.conf Linking
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2007, 19:23

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.