Static Build for Mipsel Linux
Posted: Tue Feb 05, 2013 7:28 pm
I'm trying to compile some static binaries for mipsel devices. Usually these work out better for use with different router firmwares and devices. I can get all the libraries to compile statically except for libdl which is needed by openssl.
I get the following errors
Usually I can throw "-ldl" in LDFLAGS, and that works for all the other libraries (-lc) for example, but I cannot get it to take in libdl.
I've tried seemingly everything, what else can I try?
Here's my attempt, there is more here than needed (LIBS, for example I believe), but it works to compile with dynamic libdl, and static everything else.
edit: Actually, to even to get it to compile statically with libc and libpthread etc, I have to delete the dynamic libraries from my toolchain. Placing all the "-static" and "-static-libgcc" everywhere doesn't do a thing. It seems that running configure really isn't taking into account all the options it receives for LDFLAGS.
I get the following errors
Code: Select all
/home/lance/tomatoware/opt/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text.dlfcn_globallookup+0x10): undefined reference to `dlopen'
dso_dlfcn.c:(.text.dlfcn_globallookup+0x48): undefined reference to `dlsym'
dso_dlfcn.c:(.text.dlfcn_globallookup+0x60): undefined reference to `dlclose'
dso_dlfcn.c:(.text.dlfcn_globallookup+0x30): undefined reference to `dlopen'
dso_dlfcn.c:(.text.dlfcn_globallookup+0x50): undefined reference to `dlsym'
dso_dlfcn.c:(.text.dlfcn_globallookup+0x64): undefined reference to `dlclose'
I've tried seemingly everything, what else can I try?
Here's my attempt, there is more here than needed (LIBS, for example I believe), but it works to compile with dynamic libdl, and static everything else.
Code: Select all
BASE=`pwd`
SRC=$BASE/src
WGET="wget --prefer-family=IPv4"
PATCHES=$BASE/patches
RPATH=/opt/lib
DEST=$BASE/opt
LDFLAGS="-L$DEST/lib -s -Wl,--dynamic-linker=/opt/lib/ld-uClibc.so.0 -Wl,-rpath,$RPATH -Wl,-rpath-link,$DEST/lib"
CPPFLAGS="-I$DEST/include -I$DEST/include/ncurses"
CFLAGS="-mtune=mips32 -mips32"
CONFIGURE="./configure --prefix=/opt --host=mipsel-linux"
MAKE="make -j`nproc`"
LIBEVENT_CFLAGS="-I$DEST/include -I$DEST/include/ncurses" \
LIBEVENT_LIBS=$DEST/lib/libevent.la \
LDFLAGS="-static -static-libgcc $LDFLAGS -L/opt/entware-toolchain/lib -lrt -lssl -lcrypto -ldl -pthread -lc -levent -lcurl -lz -lm -Wl,-zmuldefs" \
CPPFLAGS="-static -static-libgcc $CPPFLAGS -I/opt/entware-toolchain/include" \
CFLAGS="-static -static-libgcc $CFLAGS" \
$CONFIGURE \
--enable-lightweight \
--disable-shared --enable-cli --enable-daemon --enable-static
$MAKE \
CXX="mipsel-linux-g++ -static" \
LIBS="-static -lrt -lssl -lcrypto -ldl -pthread -lc -levent -lcurl -lz -lm" \
LDFLAGS="-static -static-libgcc $LDFLAGS -L/opt/entware-toolchain/lib -lrt -lssl -lcrypto -ldl -pthread -lc -levent -lcurl -lz -lm -Wl,-zmuldefs"