Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Building Qt as static libraries and linking on RedHat 7.2
Forum Updated to NodeBB v4.3 + New Features

Building Qt as static libraries and linking on RedHat 7.2

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
static librarystatic linking
17 Posts 3 Posters 6.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Simon PlattenS Simon Platten

    I have a system running RedHat 7.2, we have a commercial license for Qt and are getting ready to deploy and application, however we would like to statically link the application with the Qt library and other shared object libraries to make deployment easier.

    I found several online tutorials and posted yesterday on how to build a static library, however:

    1. I can't find that post.
    2. Although I managed to build a static library, I then built it and linked the application, ran it and it crashed immediately.

    I'm now trying to rebuild Qt on another system and am struggling with building the static Qt libraries. Can anyone point me to a reliable and tested source that I can follow?

    We are using Qt 5.6

    Thank you,

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by kshegunov
    #2

    @Simon-Platten said in Building Qt as static libraries and linking on RedHat 7.2:

    we would like to statically link the application with the Qt library and other shared object libraries to make deployment easier.

    As usual, my advice is: don't do it, use shared objects.

    I then built it and linked the application, ran it and it crashed immediately.

    How do you mean? What crashed? What's the error?

    Can anyone point me to a reliable and tested source that I can follow?

    This one looks about right.

    Read and abide by the Qt Code of Conduct

    1 Reply Last reply
    0
    • Simon PlattenS Offline
      Simon PlattenS Offline
      Simon Platten
      wrote on last edited by Simon Platten
      #3

      Thank you, I retraced my steps and this is the link I was originally using and am now using again:

      http://doc.qt.io/qt-5/linux-deployment.html

      The reason for static over dynamic is to simplify the role out, we are using Qt for development and as far as I am aware they're isn't a package and deployment tool that would help greatly and if it existed would mean we could use the shared object libraries.

      [Edit] The build of the static libraries has finished however, I don't see libQt5SerialPort.a which I need...

      Kind Regards,
      Simon Platten

      kshegunovK 1 Reply Last reply
      0
      • Simon PlattenS Simon Platten

        Thank you, I retraced my steps and this is the link I was originally using and am now using again:

        http://doc.qt.io/qt-5/linux-deployment.html

        The reason for static over dynamic is to simplify the role out, we are using Qt for development and as far as I am aware they're isn't a package and deployment tool that would help greatly and if it existed would mean we could use the shared object libraries.

        [Edit] The build of the static libraries has finished however, I don't see libQt5SerialPort.a which I need...

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #4

        @Simon-Platten said in Building Qt as static libraries and linking on RedHat 7.2:

        as far as I am aware they're isn't a package and deployment tool that would help greatly and if it existed would mean we could use the shared object libraries.

        It exists - the Qt Maintenance Tool. It allows you to select what binaries to install (compiler compatibility/Qt version) and where. If it's for development only, I usually use my own build from git. Static lib is really, really bad idea for development, the linker step can take forever. Also you can build Qt (or rather the QtBase module) dynamically and build anything that depends on it statically, with the assumption the modules you need are relatively small (as is with QtSerialPort).

        The build of the static libraries has finished however, I don't see libQt5SerialPort.a which I need

        Did you do an install? Usually it'd be in <QT_SOURCE_DIR>/src/qtserialport/lib if you didn't install.

        Kind regards.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        0
        • Simon PlattenS Offline
          Simon PlattenS Offline
          Simon Platten
          wrote on last edited by Simon Platten
          #5

          Thank you I am rebuilding the library now. The static build is intended purely for deployment and release not development.

          I though the maintenance tool was for system recovery, didn't realise it was for deployment.

          [Edit] I just ran the Maintenance tool and it is as I thought a recovery and removal tool. There is nothing in it to help deployment and packaging.

          Kind Regards,
          Simon Platten

          kshegunovK 1 Reply Last reply
          0
          • Simon PlattenS Simon Platten

            Thank you I am rebuilding the library now. The static build is intended purely for deployment and release not development.

            I though the maintenance tool was for system recovery, didn't realise it was for deployment.

            [Edit] I just ran the Maintenance tool and it is as I thought a recovery and removal tool. There is nothing in it to help deployment and packaging.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by kshegunov
            #6

            @Simon-Platten said in Building Qt as static libraries and linking on RedHat 7.2:

            I though the maintenance tool was for system recovery, didn't realise it was for deployment

            It is not. It's for development. For deployment, there's the specific Qt tool for windows and osx, for linux you'd usually not deploy Qt along (at least I don't).
            EDIT: I've misread your post, sorry for the confusion about the Qt Maintenance tool.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • Simon PlattenS Offline
              Simon PlattenS Offline
              Simon Platten
              wrote on last edited by
              #7

              No problem, what I would like is a packager that identifies what libraries are required, grabs them and packages then into an installer that we can use for installations and be assured that nothing is missing.

              Kind Regards,
              Simon Platten

              kshegunovK 1 Reply Last reply
              0
              • Simon PlattenS Simon Platten

                No problem, what I would like is a packager that identifies what libraries are required, grabs them and packages then into an installer that we can use for installations and be assured that nothing is missing.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #8

                @Simon-Platten said in Building Qt as static libraries and linking on RedHat 7.2:

                No problem, what I would like is a packager that identifies what libraries are required, grabs them and packages then into an installer that we can use for installations and be assured that nothing is missing.

                That's the thing, you shouldn't ... it's sounds counterintuitive I know, but Linux distros have their own repository and in that repository there's Qt, to which you should stick. Qt is binary compatible just for that reason, the API is allowed to (breakingly) change only between major versions, which means that things developed with Qt 5.0 should work out of the box if you just substitute the target of the libQt5Core.so symbolic link from libQt5Core.so.5.0.0 to libQt5Core.so.5.7.0. You can deploy Qt binaries as well, but it starts to get really painful if there's a change in one of the underlying libraries the Qt platform integration plugins depend on. Same problem with static builds, you can't build the kernel API statically, right, plus you get one big monster executable and you need to initialize the plugins Qt uses manually from code (which Qt does automagically when the loader loads the corresponding .so). Just my 2 cents.

                If you still decide to walk the "deploy Qt binaries" way then the Qt documentation provides a relatively comprehensive text, as you've already found out, on how to do it.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • Simon PlattenS Offline
                  Simon PlattenS Offline
                  Simon Platten
                  wrote on last edited by Simon Platten
                  #9

                  Now I'm confused, what are you saying...I have built at least 4 RedHat 7.2 systems and none of these had the Qt shared object libraries after the install. This is why we are looking at static builds.

                  I've just relinked our application with the static libraries and I get:

                  This application failed to start because it could not find or load the Qt platform plugin "xcb"
                  in "".

                  Reinstalling the application may fix this problem.
                  Aborted (core dumped)

                  [Edit] I've run ldd on the application and noted the referneced libraries, I added all these to the project but it still comes up with the same error.

                  Kind Regards,
                  Simon Platten

                  kshegunovK 1 Reply Last reply
                  0
                  • Simon PlattenS Simon Platten

                    Now I'm confused, what are you saying...I have built at least 4 RedHat 7.2 systems and none of these had the Qt shared object libraries after the install. This is why we are looking at static builds.

                    I've just relinked our application with the static libraries and I get:

                    This application failed to start because it could not find or load the Qt platform plugin "xcb"
                    in "".

                    Reinstalling the application may fix this problem.
                    Aborted (core dumped)

                    [Edit] I've run ldd on the application and noted the referneced libraries, I added all these to the project but it still comes up with the same error.

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #10

                    @Simon-Platten said in Building Qt as static libraries and linking on RedHat 7.2:

                    none of these had the Qt shared object libraries after the install.

                    Have you installed Qt from the distribution's repository? I work on Debian (testing), here's what I have for Qt, all precompiled and ready to be installed.

                    This application failed to start because it could not find or load the Qt platform plugin "xcb"
                    in "".

                    As I said, with static linkage the plugins must be loaded from code.

                    Look here and here for more info. It should be enough to add:

                    CONFIG += static
                    

                    for your application, so I'd start there.

                    Kind regards.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    0
                    • Simon PlattenS Offline
                      Simon PlattenS Offline
                      Simon Platten
                      wrote on last edited by Simon Platten
                      #11

                      Thank you, will look into this....

                      hmm...I found one post from last year:

                      https://blog.qt.io/blog/2015/06/24/qt-is-coming-to-red-hat-enterprise-linux/

                      However there isn't any recent activity on this and I'm not sure that Qt5.6 libraries are available from any repositories.

                      Kind Regards,
                      Simon Platten

                      kshegunovK 1 Reply Last reply
                      0
                      • Simon PlattenS Simon Platten

                        Thank you, will look into this....

                        hmm...I found one post from last year:

                        https://blog.qt.io/blog/2015/06/24/qt-is-coming-to-red-hat-enterprise-linux/

                        However there isn't any recent activity on this and I'm not sure that Qt5.6 libraries are available from any repositories.

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #12

                        @Simon-Platten said in Building Qt as static libraries and linking on RedHat 7.2:

                        However there isn't any recent activity on this and I'm not sure that Qt5.6 libraries are available from any repositories.

                        I can't say, sorry. You may be right that there isn't a prebuilt binary, I never cared much for the RedHat family, so I'm not up to date.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0
                        • Simon PlattenS Offline
                          Simon PlattenS Offline
                          Simon Platten
                          wrote on last edited by
                          #13

                          I have no choice the company I'm contracting to required a licensed version of Linux.

                          Kind Regards,
                          Simon Platten

                          kshegunovK 1 Reply Last reply
                          0
                          • Simon PlattenS Simon Platten

                            I have no choice the company I'm contracting to required a licensed version of Linux.

                            kshegunovK Offline
                            kshegunovK Offline
                            kshegunov
                            Moderators
                            wrote on last edited by kshegunov
                            #14

                            @Simon-Platten said in Building Qt as static libraries and linking on RedHat 7.2:

                            I have no choice the company I'm contracting to required a licensed version of Linux.

                            I didn't mean to imply that you should switch, I only meant that I am not up to date with RedHat and what it provides.

                            Read and abide by the Qt Code of Conduct

                            1 Reply Last reply
                            0
                            • Simon PlattenS Offline
                              Simon PlattenS Offline
                              Simon Platten
                              wrote on last edited by
                              #15

                              Thats ok, no offence taken :)

                              Kind Regards,
                              Simon Platten

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                Hi,

                                Just in case, there's a WIP tool available here which goal is to be integrated in Qt in the long run.

                                Hope it helps

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                kshegunovK 1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  Hi,

                                  Just in case, there's a WIP tool available here which goal is to be integrated in Qt in the long run.

                                  Hope it helps

                                  kshegunovK Offline
                                  kshegunovK Offline
                                  kshegunov
                                  Moderators
                                  wrote on last edited by
                                  #17

                                  @SGaist
                                  This is so new and fresh, I love it. I'll consider making a few pull requests in the near future. :)

                                  Read and abide by the Qt Code of Conduct

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved