[CMake] Forcing linking compatability to old libc / libstdc++ (Linux)

Michael Ellery mellery451 at gmail.com
Thu Jan 26 16:35:28 EST 2017


> On Jan 26, 2017, at 1:23 PM, Gonzalo Garramuño <ggarra13 at gmail.com> wrote:
> 
> I currently own an Ubuntu Xenial 14.04.1 LTS box in which I do all my work.    I distribute a binary image viewer.   However, recently one of my users tried to run the viewer on a CentOS 7 distro and found out that that distro libc and libstdc++ are older and incompatible.
> 
> I would like to compile my program targeting the older libc and libstdc++.  Those files come with symbol version and visibility. Is there an easy way to do that other than copying the old libraries?
> 
> Any help or hint is appreciated.
> 

In what way is the stdlib incompatible? Does it have bugs, or is this more a matter of cpp standard support? If you want to enforce/require a certain standard of cpp, for instance, have a look at:

https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD_REQUIRED.html

If you want to enforce certain language features, you can consider specifying compile-features:

https://cmake.org/cmake/help/v3.1/manual/cmake-compile-features.7.html
https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES

Now, that might still not solve the immediate problem of an old toolchain on Centos7, but at least CMake will make clear to the user what’s missing.  For Centos/Redhat specifically, I’ve had good luck with devtoolset for installing/using an updated toolchain:

https://www.softwarecollections.org/en/scls/rhscl/devtoolset-3

HTH,
Mike Ellery





More information about the CMake mailing list