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. Statically linking shared libraries for cross compilation
Forum Updated to NodeBB v4.3 + New Features

Statically linking shared libraries for cross compilation

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
6 Posts 2 Posters 2.7k Views 1 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.
  • L Offline
    L Offline
    lx_frz
    wrote on last edited by
    #1

    I am having problems with cross compiling Qt for an external embedded board. I managed to fix several missing dependencies by switching to static compilation, but doing this did not include libstdc++.so.6, which is causing problems still.

    Here are things I have tried:

    1. Adding the -static flag while building Qt
    2. Adding the -static-runtime flag while building Qt
    3. Adding CONFIG += static to my .pro file
    4. Adding CONFIG += staticlib to my .pro file
    5. Adding QMAKE_LFLAGS += -static-libstdc++ to my .pro file
    6. Adding LIBS += -L/opt/Xilinx/SDK/2015.4/arm/lin/libc/usr/lib/ -lstdc++ to my .pro file
    7. Adding LIBS += /opt/Xilinx/SDK/2015.4/arm/lin/libc/usr/lib/libstdc++.a to my .pro file

    None of these things have statically linked the library, when I try to use the executable on my target platform it still fails due to the missing .so

    Can someone explain how to static link libstdc++.so.6 in a QtCreator project?

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

      Hi,

      You don't, you have to first compile libstdc++ statically before you can do that.

      From the looks of it, it seems that your target sysroot is missing libraries. You should take the time to look into that.

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

      L 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You don't, you have to first compile libstdc++ statically before you can do that.

        From the looks of it, it seems that your target sysroot is missing libraries. You should take the time to look into that.

        L Offline
        L Offline
        lx_frz
        wrote on last edited by
        #3

        @SGaist In the location where I have libstdc++.so.6 on my build computer I also have libstdc++.a, is that not the static version? Since I already seem to have that, how do I get Qt to use it instead of the .so.6?

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

          IIRC, if the linker finds both the static and dynamic version in the same folder, it will use the dynamic.

          You can try to pass -Bstatic -lstdc++ or use the full path. You'll have to modify the mkspec you are using to build Qt. You should even consider copying it and give it a new name so you ensure that you can still choose the original when needed.

          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
          • L Offline
            L Offline
            lx_frz
            wrote on last edited by
            #5

            OK, I will try the -Bstatic suggestion.

            Could you elaborate on what you mean by modify the mkspec?

            Additionally, your other suggestion was to use the full path of the static library. The 7th thing I listed in my original post was to add: LIBS += /opt/Xilinx/SDK/2015.4/arm/lin/libc/usr/lib/libstdc++.a to my .pro file, is that not the correct syntax?

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

              Take a looks at the mkspecs folder in Qt's sources.

              It's the set of configuration Qt uses.

              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

              • Login

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