0

I built an exec on C++, however when I deploy it to the deployment machine I find errors like :`

/lib64/libc.so.6: version GLIBC_2.14 not found /usr/lib64/libstdc++.so.6: version GLIBCXX_3.4.14 not found /usr/lib64/libstdc++.so.6: version CXXABI_1.3.5 not found

This turns out because the deployment machine is rhel based system with older libc(2.12)/libstdc++(3.4.13) while my machine is ubuntu with far recent kernel and libraries. Unfortunately I cannot upgrade the deployment system.

I tried some of the usual ways to handle this like static linking (libc fails) and copying my library versions to the cluster (and run with LD_PRELOAD and -Wl,--rpath options) , but it doesn't work.I also installed an older version of gcc on my machine, but that also doesn't work.

Is there some way I can get this to work (perhaps making object code on my local machine,and linking it on the other machine). Or is there a way to compile the code on the deployment machine without copying source to it. Could this work with getting a copy of system libraries from deployment machine and try to get gcc to link with them? (any issues with that, and how to do that correctly)

Related to Compile with older libc (version `GLIBC_2.14' not found) and Deploying Yesod to Heroku, can't build statically and Build and run C++ code on different version of Linux and glibc

I am aware of one way to do this via VM , but I want to avoid it if possible.(HT Mat)

Community
  • 1
  • 1
ssj3892414
  • 25
  • 5
  • Workaround: create a VM on your dev box with the same OS version as your production target. Use that for compiling **and testing**. – Mat Aug 12 '16 at 14:29
  • Yes creating VM is possible, I wanted to try to avoid that if possible. On related note which VM might be suitable for deploying rhel on ubuntu. – ssj3892414 Aug 12 '16 at 14:52
  • Static linking requires `glibc-static` and other static library archives that you need. If you don't have static library archives, then you can't link static. – alvits Aug 12 '16 at 20:53
  • There are other solutions besides VM, e.g. setting up chroot. – Employed Russian Aug 13 '16 at 02:16
  • @EmployedRussian I kind of agree that the problem is same as the the yesod/heroku question. I myself linked to it. But none of the solution there seems to work. I maybe missing something , in which case I want to know what it is. Both static linking glibc still causes problem, and copying my own version of glibc and copying my glibc segfaults even before any part of my code begins. Compiling code on the deployment system isn't feasible. So that leaves Vm like deployment, and I wanted to know if that can be avoided – ssj3892414 Aug 13 '16 at 12:20
  • @ssj3892414 Are you reading the same answer I am reading? Are you reading it *carefully*? The answer explains why setting `LD_PRELOAD` or `LD_LIBRARY_PATH` doesn't work, unless you also use explicit loader invocation (solution #1). Also, solutions #2, #4 and #5 should work. If #1 doesn't work, ask a new question detailing *exact* steps you took, and observed result. – Employed Russian Aug 13 '16 at 16:22

1 Answers1

0

Compile you application with -static-libstdc++ option.

Manthan Tilva
  • 3,135
  • 2
  • 17
  • 41