I am not against editing the generated Makefile, which I am trying to make last ...
I'm not sure if you can set it using a shell variable and a relative path. I don't think ldd extends $ORIGIN to $ORIGIN/../lib64 . In this case, I think you need to use ldconfig to add $ORIGIN/../lib64 in the library search path. For more information, see finding the ldd search path in the Server Error section.
Since I'm not sure, I will give instructions anyway. You do not need to change the Makefile. Actually, I was unlucky in the past because things are overwritten and other things like CFLAGS and LDFLAGS are ignored.
Also see Build OpenSSL with RPATH? Your question and the question quoted is another question that converges on similar answers (there are no duplicates between them). But it does provide an OpenSSL dev position on RPATH. It was a personal email, so I shared the relevant data, not the whole message.
If you manage to insert $ORIGIN/../lib64 into the ELF partition and it works, please report it. Below I use /usr/local/ssl/lib for my RPATH. You should replace $ORIGIN/../lib64 with /usr/local/ssl/lib .
OpenSSL supports RPATH out of the box for BSD purposes (but not for others). From Configure:
The easiest way to do this for OpenSSL 1.0.2 is to add it to the linker flags during configuration
./config -Wl,-rpath=/usr/local/ssl/lib
You can also edit the string setting and RPATH . For example, I am working on Debian x86_64. So I opened the Configure file in the editor, copied linux-x86_64 , named it linux-x86_64-rpath and made the following change to add the -rpath parameter:
"linux-x86_64-rpath", "gcc:-m64 -DL_ENDIAN -O3 -Wall -Wl,-rpath=/usr/local/ssl/lib:: -D_REENTRANT::-Wl,-rpath=/usr/local/ssl/lib -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL: ${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
Above, fields 2 and 6 have been changed. They correspond to $cflag and $ldflag in the OpenSSL build system.
Then configure the new configuration:
$ ./Configure linux-x86_64-rpath shared no-ssl2 no-ssl3 no-comp \ --openssldir=/usr/local/ssl enable-ec_nistp_64_gcc_128
Finally, after make check the settings:
$ readelf -d ./libssl.so | grep -i rpath 0x000000000000000f (RPATH) Library rpath: [/usr/local/ssl/lib] $ readelf -d ./libcrypto.so | grep -i rpath 0x000000000000000f (RPATH) Library rpath: [/usr/local/ssl/lib] $ readelf -d ./apps/openssl | grep -i rpath 0x000000000000000f (RPATH) Library rpath: [/usr/local/ssl/lib]
After doing make install , then ldd will produce the expected results:
$ ldd /usr/local/ssl/lib/libssl.so linux-vdso.so.1 => (0x00007ffceff6c000) libcrypto.so.1.0.0 => /usr/local/ssl/lib/libcrypto.so.1.0.0 (0x00007ff5eff96000) ... $ ldd /usr/local/ssl/bin/openssl linux-vdso.so.1 => (0x00007ffc30d3a000) libssl.so.1.0.0 => /usr/local/ssl/lib/libssl.so.1.0.0 (0x00007f9e8372e000) libcrypto.so.1.0.0 => /usr/local/ssl/lib/libcrypto.so.1.0.0 (0x00007f9e832c0000) ...