I have the following program:
#include <iostream>
int main()
{
std::cerr << "hejsan" << std::endl;
}
Compiling it with the following command:
g++ main.cpp -Wl,-rpath,/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib -std=c++11
Running ldd returns:
ldd a.out
linux-vdso.so.1 => (0x00007ffe8f1eb000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000032f9e00000)
libm.so.6 => /lib64/libm.so.6 (0x00000032f6600000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000032f8a00000)
libc.so.6 => /lib64/libc.so.6 (0x00000032f5a00000)
/lib64/ld-linux-x86-64.so.2 (0x00000032f5600000)
As you can see it chooses libstdc++ inside /usr/lib64/libstdc++.so.6
Setting the LD_DEBUG=libs shows the following:
792127: find library=libstdc++.so.6 [0]; searching
792127: search path=/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/tls/x86_64:/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/tls:/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/x86_64:/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib (RPATH from file ./a.out)
792127: trying file=/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/tls/x86_64/libstdc++.so.6
792127: trying file=/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/tls/libstdc++.so.6
792127: trying file=/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/x86_64/libstdc++.so.6
792127: trying file=/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/libstdc++.so.6
792127: search cache=/etc/ld.so.cache
792127: trying file=/usr/lib64/libstdc++.so.6
This is the stdlib I want it to use: trying file=/app/vbuild/RHEL6-x86_64/gcc/6.2.0/lib/libstdc++.so.6 but somehow it looks like the cache is being used instead. I don't have root access and can't remove anything either. How do I solve this?
This is problem because I'm using this against a more complicated code which requires GLIBCXX higher version than the stdlib inside usr/lib64 provides.