Statically link C++ standard library or whatever library glibc is to project
-
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?
-
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?
@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. -
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.
-
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
@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.
-
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.