I have a binary that I want to run in another machine, but I'm getting this error message:
./program.run: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/ubuntu/lamodal/server/linux/./libxml2.so.2)
I'm compiling the program with g++ 8.3.0 using the option -Wl,-rpath='$ORIGIN'
, and in the directory where I've put the program binary I've also put all the shared libraries that I need. To discover which libraries I needed to put in the directory, in the machine I use to build the program I've run ldd ./program and got a list of libraries, which I proceeded to copy to the directory in the machine where I want to run my program.
However, in the target machine (i.e. the machine I want to run the program at), when I run ldd ./program
I have this output:
./program.run: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/ubuntu/lamodal/server/linux/./libxml2.so.2)
linux-vdso.so.1 (0x00007fff8a1d8000)
libwebsockets.so.13 => /home/ubuntu/lamodal/server/linux/./libwebsockets.so.13 (0x00007f5b220d8000)
libxml2.so.2 => /home/ubuntu/lamodal/server/linux/./libxml2.so.2 (0x00007f5b21ebd000)
libssl.so.1.1 => /home/ubuntu/lamodal/server/linux/./libssl.so.1.1 (0x00007f5b21e29000)
libcrypto.so.1.1 => /home/ubuntu/lamodal/server/linux/./libcrypto.so.1.1 (0x00007f5b21b40000)
libdl.so.2 => /home/ubuntu/lamodal/server/linux/./libdl.so.2 (0x00007f5b220d2000)
libstdc++.so.6 => /home/ubuntu/lamodal/server/linux/./libstdc++.so.6 (0x00007f5b2195e000)
libgcc_s.so.1 => /home/ubuntu/lamodal/server/linux/./libgcc_s.so.1 (0x00007f5b220b6000)
libpthread.so.0 => /home/ubuntu/lamodal/server/linux/./libpthread.so.0 (0x00007f5b22095000)
libc.so.6 => /home/ubuntu/lamodal/server/linux/./libc.so.6 (0x00007f5b21773000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5b213d5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5b22020000)
As you can see, most libraries that are being linked are in the $ORIGIN directory, that is /home/ubuntu/lamodal/server/linux/
, with exception of libm.so.6
and /lib64/ld-linux-x86-64.so.2
. Both of this libraries are in the directory, but it seems that the linker prefer the ones in other directories.
Some extra information about the machines:
Development machine:
Ubuntu 19.04 x86_64
Output of
ldd --version
:ldd (Ubuntu GLIBC 2.29-0ubuntu2) 2.29
Target machine:
Ubuntu 18.04.2 LTS x86_64
Output of
ldd --version
:ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27
Is there a way to force the runtime linker to first look at the $ORIGIN before it look anywhere else?
Edit I tried the answer provided by Employed Russian to this question and my build command now looks like this:
g++ -Wl,-rpath='$ORIGIN' \
-Wl,--dynamic-linker='$ORIGIN/ld-linux-x86-64.so.2' \
...
-o ./path/to/program.run
Then I've copied the ld-linux-x86-64.so.2
in the development machine (located at /lib64
) to the executable directory at the target machine. The ldd ./program.run
output remains the same. But now when I try to run ./program.run
I get No such file or directory
error, which according to some is because the runtime linker was not found. Then I tried to modify the build script to use the full path rather than using $ORIGIN
but this doesn't solve anything.