[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

static linking and opportunistic dynamic linking problem



Hi,

I've an interesting bug scenario sent to me by someone trying to build
partimage statically.
The partimage build is being done to make a small minimal-environment
binary (sort of boot-cd, etc.).

partimage depends on libnewt, which I maintain. libnewt-dev ships libnewt.a.
libnewt opportunistically links to libfribidi if it is present; it uses
dlopen() to do so.

However the partimage build fails when done with './configure
--enable-all-static', as it
(reasonably) does not link against libdl.

/bin/sh ../../libtool --silent --mode=link g++  -g -O2   -o partimage
-all-static netclient.o imagefile.o misc.o image_net.o buffer.o
gui_text.o main.o imginfo.o cbitmap.o interface_base.o interface_newt.o
interface_none.o mbr_backup.o -L/usr/lib -lslang fs/libfs.a
../shared/libshared.a -lcrypt -lz -lnewt -lbz2 -lpthread 
/usr/lib/libslang.a /usr/lib/libnewt.a /usr/lib/libssl.a
/usr/lib/libcrypto.a -lcrypto -lssl
netclient.o: In function `CNetClient::Connect(char*, unsigned short)':
/home/alastair/tmp/partimage-0.6.4/src/client/netclient.cpp:71: warning:
Using 'gethostbyname' in statically linked applications requires at
runtime the shared libraries from the glibc version used for linking
/usr/lib/libnewt.a(newt.o): In function `wchar_to_textmod_visual':
(.text+0x14d4): undefined reference to `dlerror'
/usr/lib/libnewt.a(newt.o): In function `wchar_to_textmod_visual':
(.text+0x1502): undefined reference to `dlsym'
/usr/lib/libnewt.a(newt.o): In function `wchar_to_textmod_visual':
(.text+0x1825): undefined reference to `dlopen'
/usr/lib/libnewt.a(newt.o): In function `wchar_to_textmod_visual':
(.text+0x1838): undefined reference to `dlerror'
/usr/lib/libnewt.a(newt.o): In function `wchar_to_textmod_visual':
(.text+0x185d): undefined reference to `dlopen'
/usr/lib/libnewt.a(newt.o): In function `wchar_to_textmod_visual':
(.text+0x189f): undefined reference to `dlerror'

Now,
 nm /usr/lib/libnewt.a  | grep dlopen
   U dlopen

So where do people think the bug lies?
 - Should libdl be compiled into libnewt.a ?
 - Should the static version of libnewt be built differently so as to
not call dlopen()?
    - if so, any recommendations on how?
 - Is the bug in partimage?

Regards
Alastair McKinstry



Reply to: