Search code examples
linkeropensslldconfigurerpath

How to set --rpath in configure script for openssl


I have different openssl versions on my system and I don't want to install the most current openssl version into the system location - e.q. /usr/bin/openssl.

Now, when I compile openssl then I get this running ldd:

root => ldd /FaF/openssl/bin/openssl
        linux-vdso.so.1 (0x00007ffe60d92000)
    --> libssl.so.1.1 => not found
    --> libcrypto.so.1.1 => not found
        libdl.so.2 => /lib64/libdl.so.2 (0x00007facf337b000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007facf315e000)
        libc.so.6 => /lib64/libc.so.6 (0x00007facf2dbd000)
        /lib64/ld-linux-x86-64.so.2 (0x00007facf357f000)

I refer to libssl.so.1.1 and libcrypto.so.1.1 which are not found and this is OK that far.

Running ldd with preceded LD_LIBRARY_PATH works:

root => LD_LIBRARY_PATH=/FaF/openssl/lib/ ldd /FaF/openssl/bin/openssl
        linux-vdso.so.1 (0x00007fff221a1000)
        libssl.so.1.1 => /FaF/openssl/lib/libssl.so.1.1 (0x00007f45f842a000)
        libcrypto.so.1.1 => /FaF/openssl/lib/libcrypto.so.1.1 (0x00007f45f7f9a000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f45f7d96000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f45f7b79000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f45f77d8000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f45f869b000)

/FaF/openssl/lib is the directory where the correct libraries are.

I have now these possible solutions:

  1. Adding /FaF/openssl/lib to /etc/ld.so.conf and running ldconfig - This is not really an option because it may break the system version of openssl.
  2. As I did in the above example I can precede each time I need opensslwith LD_LIBRARY_PATH=/FaF/openssl/lib/ - not really a good option and it isn't always possible.
  3. I can link the path with --rpath=/FaF/openssl/lib into openssl.

My question:
For the moment I didn't figure out how to set --rpath=/FaF/openssl/lib in the configure command which generates openssl. Can somebody provide me this information?

I tried setting LD_LIBRARY_PATH and LDFLAGS but nothing works.

I prefer a solution which is hard-coded into openssl so there are not other settings required.


Solution

  • OK. Here is the - very simple - way how to solve it according to 3) from my question.

    I ran ./config -h and got this output:

    root => ./config -h
    Usage: config [options]
     -d     Build with debugging when possible.
     -t     Test mode, do not run the Configure perl script.
     -v     Verbose mode, show the exact Configure call that is being made.
     -h     This help.
    
    Any other text will be passed to the Configure perl script.
    See INSTALL for instructions.
    
    Operating system: x86_64-whatever-linux2
    Configuring for linux-x86_64
    

    The text Any other text will be passed to the Configure perl script. says it all.

    I just added the --rpath at the end to the config command which looks now like this:
    ./config --prefix=/FaF/openssl threads shared -Wl,--rpath=/FaF/openssl/lib