今天编译ffmepg 报错,找了半天原因,后来发现只有在 64 位系统是才会报这种错误!
错误如下:
/usr/lib64/gcc/x86_64-linux/4.2.0/../../../../x86_64-linux/bin/ld: /usr/local/libnut.a(z.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/libnut.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
/usr/local/libnut.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
在网上搜索的解决办法如下:
You will get these messages on x86_64 any place that libtool tries to use a static (.a) library in a .la, and as it says, it can't link. These "recompile with -fPIC" messages fall into three types -
1.recompile the current package with -fPIC
2.fix a broken symlink (I had a dangling symlink for ncurses in my scripts, because of a typo - on x86 libtool couldn't find the .so but took the .a and ran with it, on x86_64 it barfed)
3.convert a Makefile to use .la instead of .a (very uncommon)
但是我使用 第二中方法还是不行,所以我就用第一种方法.重新编译了一下 libnut
shell $> cd libnut
shell $> vim config.mak
PREFIX = /usr/local
prefix = $(DESTDIR)$(PREFIX)
prefix = $(DESTDIR)$(PREFIX)
#CFLAGS += -DDEBUG
CFLAGS += -Os -fomit-frame-pointer -g -Wall
-fPIC ###加入 -fPIC 参数
CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
CC = cc
RANLIB = ranlib
AR = ar
RANLIB = ranlib
AR = ar
shell $>make libnut
shell $> make prefix=/usr install-libnut
再编译ffmpeg
shell $> cd ffmpeg
shell $> ./configure --prefix=/usr --enable-gpl --enable-nonfree --enable-pthreads --disable-ipv6 --enable-small --enable-bzlib --enable-libamr-nb --enable-libamr-wb --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --disable-debug --enable-shared
shell $> make
shell $> make
shell $> make install
OK 问题解决~~
本文转自Deidara 51CTO博客,原文链接:http://blog.51cto.com/deidara/154166,如需转载请自行联系原作者