Running C++11 shared library with older gcc, libc

Kai Ruottu kai.ruottu@wippies.com
Thu Jun 23 11:40:00 GMT 2016


23.6.2016, 13:59, Dinesh Pathak kirjoitti:
> Hi, I have written a shared library using C++11 features, compiled
> with gcc 4.8, libc 2.18, which needs to be run on a client's CentOS 6
> machine, which has gcc 4.4.7, libc 2.12. There are some symbols in
> this library which are not found in libc 2.12, so how can I use this
> library on CentOS 6. I have flexibility in how, where, which machine
> the library can be compiled, but eventually it should be usable on
> client CentOS 6, where packages can not be touched.
> If I compile the library using DevTools-2 on CentOS 6, can there can
> be any ABI related issues between these two versions of gcc/g++.
> Please let me know if there are any other suggestions.Thanks in advance.
The normal solution in these "another run-time host for apps" is to make 
a cross-
toolchain (binutils + GCC) for this another host on the development 
(build) host.
In this case the CentOS 6 glibc-2.12 and kernel headers would be 
copied/installed/unpacked
from their RPM packages and put into a suitable $sysroot on the development
system ('lib*', 'usr/include', 'usr/lib*' in the $sysroot). Then GNU 
binutils and GCC
would be built, using '--with-sysroot=$sysroot' in their configure to 
tell where the
target system's C libraries and headers are.  Very simple in principle 
and the only
expected problems usually are how to unpack '.rpm' packages (like 
'.zip', '.tar.gz',
'.tar.bz2', '-tar.xz',...), how to choose that '$sysroot' and what other 
options the
binutils and GCC configures would need... (The GCC configure options 
would usually
be partly be copied from the configure command used for the native GCC 
on the
target, here gcc-4.4.7 for CentOS 6).

For years all my self-built GCCs have been only crosscompilers because 
they are
"portable", can be copied in their binary format onto the new 
development host.
The backwards binary compatability makes sure that they will run also on 
it. My
current "run-time host" is CentOS 5 but switching to CentOS 6 could be 
motivated,
in home use I have a couple of PCs with the latest CentOS 5. Updating 
them to 6
could happen...



More information about the Gcc-help mailing list