Philipp Gebhard
Philipp Gebhard

Reputation: 301

Cross compile on Fedora 18 for Centos 6.4

I am working on a Project, which uses classes from the C++11 standard, on a Fedora 18 machine and want to deploy it on a Centos 6.4 server.

I was able to resolve all loader errors except for the libc and libc++ versions, which are GLIBC_2.11, GLIBCXX_3.4.15 and on my Fedora machine GLIBC_2.14 and at least GLIBCXX_3.4.17 respectively.

Is it possible to tell the compiler to compile/link for the server versions or older compatible versions of the libraries?

When i run ldd executable i get

./executable: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./executable)
./executable: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./executable)

Thanks in advance!

Upvotes: 2

Views: 2385

Answers (1)

Jonathan Wakely
Jonathan Wakely

Reputation: 171253

Instead of manually copying libraries to a separate directory you could set up a chroot contaiing the CentOS build env, using mock and the epel-6-x86_64 config.

Use yum in the mock chroot to install the packages you want (e.g. Qt) and build in there, that will ensure the code only uses the CentOS 6 libs that are installed in the chroot, not the rest of the packages on your Fedora OS.

Update:

When I'm using a mock chroot for building GCC I do this:

# only need these steps once to setup the chroot
mock -r fedora-19-x86_64 --init
mock -r fedora-19-x86_64 --install yum
mock -r fedora-19-x86_64 --shell 'mkdir -p /builddir/gcc/src /builddir/gcc/build'
su -c 'mount --bind $PATH_TO_GCC_SOURCES /var/lib/mock/fedora-19-x86_64/root/builddir/gcc/src'
# enter root password
mock -r fedora-19-x86_64 --shell
# now in chroot
yum install gmp-devel mpfr-devel libmpc-devel flex autogen
su - mockbuild
cd gcc/build
../src/configure --prefix=/builddir/gcc/install ... etc. ...

For your purpose you'd replace fedora-19 with epel-6

The bind mount means I don't need to have the GCC sources in the chroot, I can use the existing copy in my normal filesystem. See http://gcc.gnu.org/wiki/InstallingGCC for info on building GCC

Once you install GCC in the chroot you can use it to build your own programs then package them up for CentOS.

To go back into the chroot again later:

mock -r fedora-19-x86_64 --shell
su - mockbuild

Upvotes: 5

Related Questions