Results 1 to 14 of 14

Thread: Static Linux Builds

  1. #1
    Join Date
    Jul 2016
    Location
    Tokyo, Japan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Static Linux Builds

    Hi all,

    I'm relatively new to Qt.
    I tried to build my first application, which works perfectly fine on my own Linux machine.
    However, I shared it with an online friend, and my husband, and they could not run it on their Linux machines.

    Now I have been reading that I need to build my application statically.
    I even found the official guide (linky), but it doesn't provide the first and most important step: Download link to the libraries.
    I have also found this guide (http://qtnbeyond.blogspot.jp/2011/03...reator-in.html), but this one is meant for the older version, and the download link there doesn't work.

    So, can somebody at least explain me what to do now?

    ~Yami

    PS: Sorry for my English, I'm Japanese.

  2. #2
    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: Static Linux Builds

    Qt sources can be downloaded from here http://download.qt.io/official_releases/qt/

    Another option aside from statically linking is to bundle the dynamic libraries with the application and letting a start script set the environment such that the bundled libraries are found.

    This can be done with a custom script and any archive, e.g. ZIP, or with something like http://appimage.org/

    Cheers,
    _

  3. #3
    Join Date
    Jul 2016
    Location
    Tokyo, Japan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Static Linux Builds

    Okay, I found the source during before your reply, and I have re-compiled Qt5 with the "-static" flag, but nothing seems to be changed.
    Whatever I build now is still dynamically linked...
    The only difference is, I'm on Qt 5.7 now, instead of Qt 5.6.

  4. #4
    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: Static Linux Builds

    When you build your application you need to check that it actually builds against your Qt, not that installed in the system.

    I.e. make sure you run qmake from your custom Qt.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2016
    Location
    Tokyo, Japan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Static Linux Builds

    I think I'll need to re-install it to a different directory, as I actually overwrote the previous installation.
    How do I make sure Qt5 gets installed somewhere else (for example, in the "/opt" folder)?

  6. #6
    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: Static Linux Builds

    When you run "configure" you can pass the install path as the "-prefix" commandline switch

    Cheers,
    _

  7. #7
    Join Date
    Jul 2016
    Location
    Tokyo, Japan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Static Linux Builds

    And after wasting yet another 5 hours of my life, "make" stopped here:

    Qt Code:
    1. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtQuick2Plugin()'
    2. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtQuick2Plugin()'
    3. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtQuick2WindowPlugin()'
    4. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtQuick2WindowPlugin()'
    5. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtQuickLayoutsPlugin()'
    6. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtQuickLayoutsPlugin()'
    7. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QmlFolderListModelPlugin()'
    8. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QmlFolderListModelPlugin()'
    9. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtVirtualKeyboardStylesPlugin()'
    10. /opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.a(plugin.o):plugin.cpp:function QVirtualKeyboardPlugin::create(QString const&, QStringList const&): error: undefined reference to 'qt_static_plugin_QtVirtualKeyboardStylesPlugin()'
    11. collect2: error: ld returned 1 exit status
    12. make[4]: *** [Makefile:71: basic] Error 1
    13. make[4]: Leaving directory '/opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/examples/virtualkeyboard/basic'
    14. make[3]: *** [Makefile:43: sub-basic-make_first] Error 2
    15. make[3]: Leaving directory '/opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/examples/virtualkeyboard'
    16. make[2]: *** [Makefile:43: sub-virtualkeyboard-make_first] Error 2
    17. make[2]: Leaving directory '/opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard/examples'
    18. make[1]: *** [Makefile:70: sub-examples-make_first] Error 2
    19. make[1]: Leaving directory '/opt/qt-everywhere-opensource-src-5.7.0/qtvirtualkeyboard'
    20. make: *** [Makefile:804: module-qtvirtualkeyboard-make_first] Error 2
    21. [root@Linux qt-everywhere-opensource-src-5.7.0]
    To copy to clipboard, switch view to plain text mode 

  8. #8
    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: Static Linux Builds

    You could check if the build has already progressed far enough for your needs.

    I.e. if those libraries in Qt that your application needs have already been built.

    Cheers,
    _

  9. #9
    Join Date
    Jul 2016
    Location
    Tokyo, Japan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Static Linux Builds

    Okay, I tried again with the "-skip qtvirtualkeyboard" parameter, and it seems like it got installed successfully this time.
    Now I tried to build it as static, and that also seemed to work.

    Now I only need to get it running on different Distributions (I'm using Arch Linux), those with Ubuntu and Linux Mint didn't seem to get it to run.
    They get this error:
    Qt Code:
    1. Cannot execute binary file: Exec format error
    To copy to clipboard, switch view to plain text mode 

    Edit:
    I tried it on 2 Live Sessions (one with Linux Mint, and one with Manjaro), and on Windows 10's Ubuntu Sub System.
    All 3 of them can't run my application, due to missing libraries (libwebp, libmng, etc.).
    Is there something I'm missing?
    Last edited by MKGirlism; 29th July 2016 at 10:27.

  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: Static Linux Builds

    Hmm, that's a strange error

    Are you perhaps building a 64-bit executable and the target systems are 32-bit?

    As for the libraries, those need to be either in the system, bundled with the application (see comment #2) or statically linked.
    Or Qt confgured to skip support for these formats.

    Cheers,
    _

  11. #11
    Join Date
    Jul 2016
    Location
    Tokyo, Japan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Static Linux Builds

    And how do I statically link these 3rd party libraries?
    I already got Qt-specific libraries statically linked, although I find it pointless to include, let's say, "libwebp", while the App has absolutely nothing to do with networking...

  12. #12
    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: Static Linux Builds

    Quote Originally Posted by MKGirlism View Post
    And how do I statically link these 3rd party libraries?
    You need the static build of those libraries.

    Which is why usually no one does static linking, as it is way too much work.

    Quote Originally Posted by MKGirlism View Post
    I already got Qt-specific libraries statically linked, although I find it pointless to include, let's say, "libwebp", while the App has absolutely nothing to do with networking...
    This has nothing to do with networking, WebP is an image format.

    Usually these are plugins but since you are doing a static build of Qt these are now built into Qt.

    You can likely disable them during configure, as I said above.

    Or just not statically link Qt and only ship the image plugins you need.

    Cheers,
    _

  13. #13
    Join Date
    Jul 2016
    Location
    Tokyo, Japan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Static Linux Builds

    Quote Originally Posted by anda_skoa View Post
    You need the static build of those libraries.
    Well, yes...quite obvious that in order to statically linking libraries, I need to statically link libraries... ( ̄ー ̄。)
    I actually asked how I should do that.
    I already tried copying stuff from "/usr/lib64", and included those libraries within the .tar.gz file I would distribute the application with, but that didn't help neither.

  14. #14
    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: Static Linux Builds

    Quote Originally Posted by MKGirlism View Post
    Well, yes...quite obvious that in order to statically linking libraries, I need to statically link libraries... ( ̄ー ̄。)
    I actually asked how I should do that.
    Similar to Qt: you get the sources for these libraries and configure and make static build.

    Quote Originally Posted by MKGirlism View Post
    I already tried copying stuff from "/usr/lib64", and included those libraries within the .tar.gz file I would distribute the application with, but that didn't help neither.
    Make sure your start script points the LD_LIBRARY_PATH variable to the directory you've put the libraries into.

    You can use "ldd" on the executable to see which libraries the runtime linker find when it tries to resolve the symbols needed by the program.

    Cheers,
    _

Similar Threads

  1. unable to make static builds on windows
    By mchome in forum Newbie
    Replies: 13
    Last Post: 16th July 2012, 19:42
  2. Something terribly wrong with static linux builds
    By snookie in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2011, 22:22
  3. Mixing static and dynamic Qt builds.
    By End in forum Newbie
    Replies: 3
    Last Post: 2nd March 2010, 22:04
  4. Size of Static Builds
    By Stobie in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 19th January 2010, 21:24
  5. Coexisting static and shared builds of QT on windows
    By doggrant in forum Installation and Deployment
    Replies: 2
    Last Post: 10th September 2009, 16:52

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.