[x264-devel] [resend] Patch to improve shared library builds
andreas.hanke at gmx-topmail.de
andreas.hanke at gmx-topmail.de
Wed Mar 15 22:32:31 CET 2006
[I'm resending this because the previous mail seems to be lost for some
reason.]
Hi,
my name is Adreas Hanke, I'm from Germany and I'd like to propose some
changes for shared library builds:
- use -fPIC not only for compilation, but also for linking if --enable-pic
was given. According to the GCC man page, this is necessary to get
"predictable results". From the man page:
"-shared
Produce a shared object which can then be linked with other objects to form
an executable. Not all systems support this option. For predictable results,
you must also specify the same set of options that were used to generate
code (-fpic, -fPIC, or model suboptions) when you specify this
option."
- use LDFLAGS for the shared library as well, not only for the executables.
Otherwise there will be undefined symbols inside the shared library:
$ ldd -r libx264.so.45
undefined symbol: pthread_create (./libx264.so.45)
undefined symbol: pow (./libx264.so.45)
undefined symbol: pthread_join (./libx264.so.45)
linux-gate.so.1 => (0xffffe000)
libc.so.6 => /lib/tls/libc.so.6 (0x4008c000)
/lib/ld-linux.so.2 (0x80000000)
The shared library needs libpthread and libm, too. Undefined symbols in
shared libraries are not fatal, but will cause problems if the calling
executable does not incidentally link to the needed libraries.
- make the unversioned symlink which is created during "make install"
relative. This solves problems for package builders (RPM/DEB): They are
using DESTDIR during "make install" which puts the files into DESTDIR
instead of "/", but the symlinks must still point to "/", not DESTDIR. This
can be bypassed by making the symlink relative.
- use the shared library for the CLI if it was enabled and use the static
library otherwise.
Patch:
--- configure
+++ configure
@@ -317,6 +317,7 @@
if [ "$pic" = "yes" ] ; then
CFLAGS="$CFLAGS -fPIC"
+ LDFLAGS="$LDFLAGS -fPIC"
ASFLAGS="$ASFLAGS -D__PIC__"
fi
--- Makefile
+++ Makefile
@@ -68,10 +68,11 @@
ranlib libx264.a
$(SONAME): .depend $(OBJS) $(OBJASM)
- $(CC) -shared -o $@ $(OBJS) $(OBJASM) -Wl,-soname,$(SONAME)
+ $(CC) -shared -o $@ $(OBJS) $(OBJASM) -Wl,-soname,$(SONAME) $(LDFLAGS)
+ ln -sf $(SONAME) libx264.so
x264$(EXE): $(OBJCLI) libx264.a
- $(CC) -o $@ $+ $(LDFLAGS)
+ $(CC) -o $@ $(OBJCLI) -L. -lx264 $(LDFLAGS)
x264vfw.dll: libx264.a $(wildcard vfw/*.c vfw/*.h)
make -C vfw/build/cygwin
@@ -141,7 +142,7 @@
install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
install x264 $(DESTDIR)$(bindir)
ranlib $(DESTDIR)$(libdir)/libx264.a
- $(if $(SONAME), ln -sf $(DESTDIR)$(libdir)/$(SONAME)
$(DESTDIR)$(libdir)/libx264.so)
+ $(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.so)
$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir))
uninstall:
--
"Feel free" mit GMX FreeMail!
Monat für Monat 10 FreeSMS inklusive! http://www.gmx.net
--
This is the x264-devel mailing-list
To unsubscribe, go to: http://developers.videolan.org/lists.html
More information about the x264-devel
mailing list