1

I have an ARM device with an non-upgradable linux kernel running on it. I want to run some C++11 programs on it, however, the system libstdc++.so.6 and libc.so.6 are too old to support C++11 at runtime. I have copies of the newer libraries, but I'm not sure how I can tell my program to use the new ones and not the old ones. I created a new directory called /tmp/newlibs, and I put copies of the new shared objects in there. Then, I compiled with the following flags:

g++ -std=c++11 -Wl,-rpath,/tmp/newlibs test.cpp -o test

But when I attempt to execute the file, I get the following error:

/test: /lib/libc.so.6: version `GLIBC_2.17' not found (required by /tmp/newlibs/libstdc++.so.6)

So clearly, the rpath flag worked for libstdc++, but it looks like it didn't work for the newer version of libc.so.6. Is there something I'm missing here? Does libstdc++.so.6 have a hard-coded path in it that I can't change?

I feel like this is a very similar problem to this question, except in my case it isn't fully utilizing my new glibc directory:

Multiple glibc libraries on a single host

Edit: it seems like the dynamic linker might be skipping over my new libc for some reason. Because when I try to preload libc.so.6 using LD_PRELOAD, I get:

ERROR: ld.so: object '/tmp/newlibs/libc.so.6' from LD_PRELOAD cannot be preloaded: ignored.

Community
  • 1
  • 1
Gillespie
  • 5,780
  • 3
  • 32
  • 54
  • Try setting LD_LIBRARY_PATH. – n. m. could be an AI Mar 11 '15 at 21:01
  • @n.m. I tried that as well - instead of using rpath, I set LD_LIBRARY_PATH instead. Same results - it finds libstdc++.so just fine, but keeps trying to use the system libc.so... – Gillespie Mar 11 '15 at 21:07
  • did you actually specify the '-Wl,--dynamic-linker=...' option? what does 'readelf -a test | grep ld' say? – Come Raczy Mar 11 '15 at 22:19
  • @ComeRaczy No, I didn't. I was trying to get the linker error like the guy in the other question before adding in that option. readelf says `[Requesting program interpreter: /lib/ld-linux.so.3]` which is the old system linker, so I guess I have to include the new linker at `/tmp/newlibs/ld-linux.so.3`? I'll try that, and comment again if the same problem persists. – Gillespie Mar 12 '15 at 14:08
  • @ComeRaczy So when I explicitly specify the new linker, I get `FATAL: kernel too old` when trying to execute `test`. Does this mean I have to rebuild `glibc` targeting the older kernel I want to use it on? – Gillespie Mar 12 '15 at 15:41
  • 1
    @RPGillespie looks like you'll need to. 'file test' should give you the minimum version currently supported. if your ARM linux kernel is older than thet you'll need to rebuild glibc specifying the configure option '--enable-kernel=ARM-kernel-version' – Come Raczy Mar 12 '15 at 19:50
  • @ComeRaczy Thanks, that worked! I was using Yocto Project (Poky) to build stuff, and since `--enable-kernel` is automatically set to `${OLDEST_KERNEL}` in Poky's glibc recipe, I just set `OLDEST_KERNEL` to the kernel I wanted them to run on and ran `bitbake` and it worked like a charm! – Gillespie Mar 20 '15 at 22:03

0 Answers0