Search code examples
linuxcross-compilingzlibuclibcdropbear

Unable to cross-compile dropbear for uclibc


I am trying to cross-compile Dropbear for an x86 machine where glibc is missing and instead, uclibc is being used. For that aim, I have cross-compiled zlib for this same instruction set using a custom crosstool-ng toolchain and installed it to a custom location.

msainz@ubuntu:~$ ls Projects/zlib_install/lib
libz.a  libz.so  libz.so.1  libz.so.1.2.11  pkgconfig

I have copied Projects/zlib_install/include/zlib.h and Projects/zlib/include/zconf.h to Projects/dropbear/zlibincludes/.

I've set my env variables this way:

msainz@ubuntu:~$ echo $PATH 
usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
/usr/local/games:/snap/bin:/home/msainz/x-tools/x86_64-multilib-linux-uclibc/bin

msainz@ubuntu:~/Projects/dropbear$ echo $LDFLAGS
/home/msainz/Projects/zlib_install/lib/libz.a

msainz@ubuntu:~/Projects/dropbear$ echo $CFLAGS
-Izlibincludes -I../zlibincludes

I launch the configure script this way: ./configure --prefix=/home/msainz/Projects/tmp_top_dir --host=x86

The execution terminates with the following error:

configure:4851: x86_64-multilib-linux-uclibc-gcc -o conftest -Izlibincludes -I../zlibincludes -Wno- 
pointer-sign -fno-strict-overflow -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mfunction- 
return=thunk -mindirect-branch=thunk  /home/msainz/Projects/zlib_install/lib/libz.a -pie -Wl,-z,now - 
Wl,-z,relro conftest.c -lz   >&5
/home/msainz/x-tools/x86_64-multilib-linux-uclibc/bin/../lib/gcc/x86_64-multilib-linux- 
uclibc/8.3.0/../../../../x86_64-multilib-linux-uclibc/bin/ld.bfd: cannot find -lz
collect2: error: ld returned 1 exit status

Any ideas to solve this? Thanks in advance.


Solution

  • Solved the problem adding --with-zlib=/home/msainz/Projects/zlib_install/ to the ./configure call.