Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Compile with dynamic Qt libraries and static gcc libraries under Linux
Forum Update on Monday, May 27th 2025

Compile with dynamic Qt libraries and static gcc libraries under Linux

Scheduled Pinned Locked Moved Installation and Deployment
9 Posts 3 Posters 7.4k Views
  • 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.
  • D Offline
    D Offline
    deleted57
    wrote on 24 Sept 2014, 08:17 last edited by
    #1

    Hi all

    I'm trying to compile my Qt application by using Qt libraries in dynamic mode and, in my intention, by linking statically all other gcc libraries (like, for example, libstdc++). Unfortunately I still didn't find a way for this.

    Currently I made some test using the QMAKE_LFLAGS option into the Qt Creator .pro file as follow:

    @QMAKE_LFLAGS += -static-libstdc++@

    but using the ldd tool I can see the libstdc++ is still linked dynamically (libstdc++.so.6). If I try the following solution:

    @QMAKE_LFLAGS += -static@

    The linker return error since want to have all the libraries in static format and, obviously, doesn't find the Qt static libraries.

    Someone know the correct way to make such result?

    Thank you

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 24 Sept 2014, 08:27 last edited by
      #2

      AFAIK, g++ automatically links the first std library it finds: static or shared. Modify your path to point to libstdc++.a first, then to the shared one.

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        deleted57
        wrote on 24 Sept 2014, 08:32 last edited by
        #3

        Hi

        Thank you for your help.

        At which level I should to modify path? (linker?) Something like:

        @QMAKE_LFLAGS += -Wl,-rpath,/path_to_static_libstdc++/@

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 24 Sept 2014, 08:52 last edited by
          #4

          Are you sure you have static libstdc+ available on your system?

          (Z(:^

          1 Reply Last reply
          0
          • D Offline
            D Offline
            deleted57
            wrote on 24 Sept 2014, 09:01 last edited by
            #5

            Yes, is in the following path:

            @/usr/lib/gcc/i486-linux-gnu/4.7/libstdc++.a@

            1 Reply Last reply
            0
            • D Offline
              D Offline
              deleted57
              wrote on 29 Sept 2014, 08:01 last edited by
              #6

              No one have a suggestion about?

              1 Reply Last reply
              0
              • D Offline
                D Offline
                deleted57
                wrote on 15 Oct 2014, 08:18 last edited by
                #7

                I'm still facing this issue.

                Tried add this flag:

                @QMAKE_LFLAGS += -static-libgcc -static-libstdc++@

                but no effect, libstdc++ still linked dynamically.

                Tried also:

                @QMAKE_LFLAGS += -Wl,-b-static-libgcc -Wl,-b-static-libstdc++@

                but linker return this error:

                @:-1: error: invalid BFD target `-static-libstdc++'@

                I can't believe there is no way to link statically libstdc++

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 15 Oct 2014, 08:53 last edited by
                  #8

                  Hi,

                  What about giving the full path to the library ?

                  IIRC something like:

                  @LIBS += /usr/lib/gcc/i486-linux-gnu/4.7/libstdc++.a@

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

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    deleted57
                    wrote on 15 Oct 2014, 09:05 last edited by
                    #9

                    Hi

                    Thank you for your reply.

                    Unfortunately your suggestion doesn't work, libstdc++ still linked dynamically. I already tried similar test by additing the

                    @LIBS += -L/usr/lib/gcc/i486-linux-gnu/4.7@

                    flasg bug same result...

                    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