I've been trying to build DirectFB, and I think that
I've narrowed down a bug in the build process to what might be a
confusing make or libtool behavior. I've been cross-compiling using
--sysroot for gcc so that everything will link against a custom set of
libraries that I've built. Here's my full configure line (the
important part is to note that --sysroot=/home/ersin/vorpo/toolchain):
DirectFB
chokes, however, when it starts to build a certain tool,
directfb-csource, that requires libpng. Here's the relevant part from
the build:
address@hidden DirectFB-1.4.3]$ make directfb-csource make -C tools directfb-csource make[1]: Entering directory `/home/ersin/vorpo/build/DirectFB-1.4.3/tools' i386-linux-gcc
--sysroot=/home/ersin/vorpo/toolchain -DHAVE_CONFIG_H -I. -I.. -I../lib
-I../include -I../include -I../lib -I../src
-DDATADIR=\"/usr/share/directfb-1.4.3\" -D_REENTRANT
-I/usr/include/freetype2 -O3 -ffast-math -pipe -Os -D_GNU_SOURCE
-Werror-implicit-function-declaration -MT directfb-csource.o -MD -MP
-MF .deps/directfb-csource.Tpo -c -o directfb-csource.o
directfb-csource.c mv -f .deps/directfb-csource.Tpo .deps/directfb-csource.Po /bin/sh
../libtool --tag=CC --mode=link i386-linux-gcc
--sysroot=/home/ersin/vorpo/toolchain -I/usr/include/freetype2 -O3
-ffast-math -pipe -Os -D_GNU_SOURCE
-Werror-implicit-function-declaration -o directfb-csource
directfb-csource.o -lpng12 -ldl
-lpthread mkdir .libs i386-linux-gcc
--sysroot=/home/ersin/vorpo/toolchain -I/usr/include/freetype2 -O3
-ffast-math -pipe -Os -D_GNU_SOURCE
-Werror-implicit-function-declaration -o directfb-csource
directfb-csource.o /usr/lib/libpng12.so -ldl -lpthread /home/ersin/vorpo/build/buildroot-2010.02/output/staging/usr/bin-ccache/../lib/gcc/i386-linux-uclibc/4.3.4/../../../../i386-linux-uclibc/bin/ld:
warning: libm.so.6, needed by /usr/lib/libpng12.so, not found (try
using -rpath or -rpath-link) /home/ersin/vorpo/build/buildroot-2010.02/output/staging/usr/bin-ccache/../lib/gcc/i386-linux-uclibc/4.3.4/../../../../i386-linux-uclibc/bin/ld:
warning: libc.so.6, needed by /usr/lib/libpng12.so, not found (try
using -rpath or -rpath-link) /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden'
/usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden'
/usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden'
/usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden'
/usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden'
/usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' /usr/lib/libpng12.so: undefined reference to address@hidden' collect2: ld returned 1 exit status
make[1]: *** [directfb-csource] Error 1 make[1]: Leaving directory `/home/ersin/vorpo/build/DirectFB-1.4.3/tools' make: *** [directfb-csource] Error 2 address@hidden DirectFB-1.4.3]$
Something strange is going on here. Look at the lines after "mkdir .libs" carefully:
i386-linux-gcc --sysroot=/home/ersin/vorpo/toolchain
-I/usr/include/freetype2 -O3 -ffast-math -pipe -Os -D_GNU_SOURCE
-Werror-implicit-function-declaration -o directfb-csource
directfb-csource.o /usr/lib/libpng12.so -ldl -lpthread
/home/ersin/vorpo/build/buildroot-2010.02/output/staging/usr/bin-ccache/../lib/gcc/i386-linux-uclibc/4.3.4/../../../../i386-linux-uclibc/bin/ld:
warning:
libm.so.6, needed by /usr/lib/libpng12.so, not found (try
using -rpath or -rpath-link)
Here's where my limited knowledge
of make starts to hinder me and where I need help. The build is trying
to link explicitly against "/usr/lib/libpng12.so", which is the libpng
path on my host machine, when it shouldn't be using an absolute path at
all. I narrowed it down, and that compile line above seems to be
related to the following in tools/Makefile:
which is clearly not gcc, but this line was the only place that I could
find the pattern "$(directfb_csource_OBJECTS) $(directfb_csource_LDADD)
$(LIBS)", which almost expands to the problematic part of the build
("i386-linux-gcc ............... directfb-csource directfb-csource.o
/usr/lib/libpng12.so -ldl -lpthread"), except for two things:
directfb_csource_LDADD = $(LIBPNG_LIBS)
and
LIBPNG_LIBS = -lpng12
So what seems to be happening is that make runs ../libtool, which
happens right before the line where gcc chokes, and somewhere between
then and when the build tries to link against my system libraries,
direct_csource_LDADD somehow turns from "-lpng12" to
"/usr/lib/libpng12.so", and then that pattern gets concatenated to the
end of the compile line. I can override this behavior by adding
LIBPNG_LIBS="/home/ersin/vorpo/toolchain/usr/lib/libpng12.so -lpng12"
to my configure line, but this is ugly and doesn't work properly anyhow
("/usr/lib/libpng12.so" is still being linked against and the build
spits out a warning, but I guess since it finds the proper symbols from
"/home/ersin/vorpo/toolchain/usr/lib/libpng12.so" it doesn't
complain). Why do these substitutions occur and how can I stop them?
If I can't stop them, can I somehow add my sysroot directory to the
beginning?