Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Statically link C++ standard library or whatever library glibc is to project

Statically link C++ standard library or whatever library glibc is to project

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 2.9k 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.
  • A Offline
    A Offline
    A123
    wrote on last edited by
    #1

    I am building an program that I can run just fine on my ubuntu based computer but is refusing to run on a remote CentOS 7 computer. It gives me these errors

    ./programs/sampleapp: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by ./programs/sampleapp)
    ./programs/sampleapp: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./programs/sampleapp)
    ./programs/sampleapp: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./programs/sampleapp)
    

    I assume they are missing libraries of I guess the C++ standard library. How can I static link these in Qt creator when I build it to get rid of the errors?

    jsulmJ 1 Reply Last reply
    0
    • A A123

      I am building an program that I can run just fine on my ubuntu based computer but is refusing to run on a remote CentOS 7 computer. It gives me these errors

      ./programs/sampleapp: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by ./programs/sampleapp)
      ./programs/sampleapp: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./programs/sampleapp)
      ./programs/sampleapp: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./programs/sampleapp)
      

      I assume they are missing libraries of I guess the C++ standard library. How can I static link these in Qt creator when I build it to get rid of the errors?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @A123 said in Statically link C++ standard library or whatever library glibc is to project:

      I assume they are missing libraries of I guess the C++ standard library

      It is not missing C++ std lib, it is GLibC which is older on CentOS 7 than on your Ubuntu. You app expects GLibC >= 2.29.
      And also C++ stdlib is too old for your app.
      Simply build your app on CentOS 7.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • A Offline
        A Offline
        A123
        wrote on last edited by
        #3

        I can do that but I want to know how to statically link the libraries so other people can run it on their linux system without having to build it themselves.

        jsulmJ 1 Reply Last reply
        0
        • A A123

          I can do that but I want to know how to statically link the libraries so other people can run it on their linux system without having to build it themselves.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @A123 For static build you need all your dependencies (including glibc, C++ stdlib and Qt) as statically built libs. This is not really an easy task. And it also makes your executable very big.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            Also static link of libstdc++ brings license implication with it. libstdc++ has GPL license with an exception when used as runtime library, if you statically link then the full GPL comes into force

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            A 1 Reply Last reply
            1
            • VRoninV VRonin

              Also static link of libstdc++ brings license implication with it. libstdc++ has GPL license with an exception when used as runtime library, if you statically link then the full GPL comes into force

              A Offline
              A Offline
              A123
              wrote on last edited by
              #6

              @VRonin okay is there an easier way? Can I just get these files that they are complaining about somewhere and put them in a folder? I had no problem building and transferring this to the remote computer but I deleted some source files to slim it down and all of a sudden its nonportable for some reason I can't figure out.

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                Can't you just run yum update/upgrade on the CentOS machine?
                These are system libraries, they are normally managed user-side, not by the application developers

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SimonSchroeder
                  wrote on last edited by
                  #8

                  The best solution is to build on the oldest system you want to support (i.e. on CentOS 7 in your case).

                  Then there is also this post on StackOverflow explaining different variations: https://stackoverflow.com/questions/2856438/how-can-i-link-to-a-specific-glibc-version

                  One suggestion is to use -static as compiler flag which will try to link to C/C++ libraries statically. From my experience you will still get a few warnings that some functions keep being linked dynamically. I got lucky so far ignoring these.

                  One thing you should know about GCC's libraries is that they have several versions of the same function. This is to provide backwards compatibility (older software should still run when updating your OS). According too the StackOverflow post there is a directive to select a specific version for GLIBC (and I bet the same is true for GLIBCXX). You could try to use this in your source code to select a version for linking which is also supported by CentOS. I would personally favor this solution over static linking.

                  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