I have built and installed another glibc from source, and I want to have existing executables written in c++ to run with the custom glibc for experimental purpose. In order to do this, i tried to change the loader of the executable. Firstly, a link named ld_linux-x86-64.so.2
was created under /lib64 , with its path pointing to the new loader
sudo ln /home/ubuntu/glibc-2.27-amd64/lib/ld-2.27.so /lib64/ld_linux-x86-64.so.2
Secondly, the loader path in the executable was modified via text editor, changing '/lib64/ld-linux-x86-64.so.2' into '/lib64/ld_linux-x86-64.so.2'. I launched the executable and got the following error:
./demo_cpp: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
The patched cpp program failed to run and it seems that the c++ std lib is missing. However, this method did work for program written by pure C. Using the method mentioned here, i tried the following command and get the exactly same error:
patchelf --set-interpreter /home/ubuntu/glibc-2.27-amd64/lib/ld-linux-x86-64.so.2 --set-rpath /home/ubuntu/glibc-2.27-amd64/lib demo_cpp
So I wonder if it is possible to change glibc for a cpp program? Do i need to build cpp std lib from source too?