LD_LIBRARY_PATH ignored?

122 views
Skip to first unread message

Mark van Leeuwen

unread,
Apr 4, 2019, 6:36:07 PM4/4/19
to Alt-F
Hello

Continuing my "self compiled" dropbear + openssh's sftp_server mentionned in https://groups.google.com/forum/#!topic/alt-f/XRV2aGbdIFE

While compiling openssl itself didn't seem to take too long (38mn on my 320L) I now hit the problem that I want to set LD_LBRARY_PATH for my self-compiled zlib and openssl when compiling openssh, or more precisely, running its ./configure script,
When compiling both zlib and openssl, I've set a "--prefix=$DIR" to change the root of the location those custom compiles woudl be installed to, and did a 

export LD_LIBRARY_PATH=$DIR/lib

When running openssh's ./configure script it says openssl cannto be found. After digging in to the script to understand what it does and how it reaches that conclusion, it appears it build a test executable extracting the major./minor version number of openssl. While compiling this executable works, executing it fails as libcrypto.so.1.1 cannot be found.  

$ cat test_executable.c
// NOTE: bunch of #define skipped from the forum post
       
#include <stdlib.h>
       
#include <stdio.h>
       
#include <string.h>
       
#include <openssl/opensslv.h>
       
#define DATA "conftest.sslincver"

int
main
()
{
                FILE
*fd;
               
int rc;

                fd
= fopen(DATA,"w");
               
if(fd == NULL)
                       
exit(1);

               
if ((rc = fprintf(fd, "%08lx (%s)\n",
                   
(unsigned long)OPENSSL_VERSION_NUMBER,
                     OPENSSL_VERSION_TEXT
)) < 0)
                       
exit(1);

               
exit(0);
 
;
 
return 0;
}

$ ldd test_executable
        libcrypto.so.1.1 => not found
        libdl.so.0 => /lib/libdl.so.0 (0xb6f7a000)
        libutil.so.0 => /lib/libutil.so.0 (0xb6f71000)
        libz.so.1 => /usr/lib/libz.so.1 (0xb6f56000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6f43000)
        libc.so.0 => /lib/libc.so.0 (0xb6ee2000)
        ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0xb6f84000)

$ ls $LD_LIBRARY_PATH
engines-1.1       libcrypto.a       libcrypto.so      libcrypto.so.1.1  libssl.a          libssl.so         libssl.so.1.1     libz.a            libz.so           libz.so.1         libz.so.1.2.11    pkgconfig

As LD_LIBRARY_PATH seems to be ignored as libcrypt and zlib shoudl have been taken from $DIR/lib
What are my options?

João Cardoso

unread,
Apr 5, 2019, 12:05:34 PM4/5/19
to Alt-F
I have not checked the issue, but I think that using LD_LIBRARY_PATH or other environment variables to control program launching or libraries path finding is not a good idea out of a debug or development environment.

Your option is to use 'rpath' to hardcode library paths in executables (or libraries that depends on other custom libraries). That is the way how entware and other self-contained environments work (by the way, have you checked if entware packages solve your requirements/concerns?)
The other option is to link statically, even disabling shared libs (and enabling only static ones) at configure time.

Reply all
Reply to author
Forward
0 new messages