编译出错 recompile with -fPIC

对作者表示深刻感谢

来源:http://blog.csdn.net/greencacti/article/details/9188679

作者:greencacti

背景:

这两天在玩ganglia这个的时候,发现这个依赖于libConfuse,先按照libConfuse以后,然后再编译ganglia的时候报错,提示"recomile with fPIC".


资料:

上网找了一下资料,发现了下文比较接近

http://deidara.blog.51cto.com/400447/154166/(下文中附)


实际解决办法:

按照上面方法,在libConfuse里面找不到对应的文件,继续探究configure文件的时候,发现有一个enable-shared参数,估计有用,按照如下步骤编译了libConfuse,然后再编译ganglia就通过了

# ./configure --enable-shared
# make
# make install

文中参考资料

来源:http://deidara.blog.51cto.com/400447/154166/

作者:Deidara

今天编译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
 
在网上搜索的解决办法如下:
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)
#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
 
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 install

原文地址:https://www.cnblogs.com/AI001/p/3368893.html