[vlc-devel] [PATCH] x264: Use -Bsymbolic to fix static link

Pierre Ynard linkfanel at yahoo.fr
Thu Mar 26 18:11:17 CET 2009


On my linux x86_64 system, when trying to statically link the x264
module against libx264, I get the following error:

/usr/bin/ld: /usr/local/lib/libx264.a(cabac-a.o): relocation
R_X86_64_PC32 against symbol `x264_cabac_range_lps' can not be used when
making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

Even though libx264 was compiled as PIC. Dynamically linking against the
shared library, built during the same process, works well.

The x264 folks said that VLC needed to use the -Bsymbolic flag to allow
conversation of a static PIC library into a shared library, so that's
what I did, and it works for me.


diff --git a/configure.ac b/configure.ac
index 82a140e..6681fc6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3743,7 +3743,7 @@ if test "${enable_x264}" != "no"; then
       VLC_ADD_LIBS([x264],[-L${real_x264_tree}])
       PKG_CHECK_MODULES(X264,x264, [
         VLC_ADD_PLUGIN([x264])
-        VLC_ADD_LDFLAGS([x264],[${X264_LIBS}])
+        VLC_ADD_LDFLAGS([x264],[${X264_LIBS} -Wl,-Bsymbolic])
         VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}])
         if echo ${X264_LIBS} |grep -q 'pthreadGC2'; then
           VLC_ADD_CFLAGS([x264], [-DPTW32_STATIC_LIB])
@@ -3759,7 +3759,7 @@ if test "${enable_x264}" != "no"; then
   else
       PKG_CHECK_MODULES(X264,x264, [
         VLC_ADD_PLUGIN([x264])
-        VLC_ADD_LDFLAGS([x264],[${X264_LIBS}])
+        VLC_ADD_LDFLAGS([x264],[${X264_LIBS} -Wl,-Bsymbolic])
         VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}])
         if echo ${X264_LIBS} |grep -q 'pthreadGC2'; then
           VLC_ADD_CFLAGS([x264], [-DPTW32_STATIC_LIB])


Regards,

-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."



More information about the vlc-devel mailing list