By Alasdair Lumsden on 19 May 2009
Note (2013-02-14): Please see the comments for useful suggestions – what I’ve written below isn’t a proper fix.
Just a very quick post regarding libx264.
If you are getting errors such as:
# gcc -shared -o libx264.so.67 common/mc.o common/predict.o common/pixel.o common/macroblock.o common/frame.o common/dct.o common/cpu.o common/cabac.o common/common.o common/mdate.o common/set.o common/quant.o common/vlc.o encoder/analyse.o encoder/me.o encoder/ratecontrol.o encoder/set.o encoder/macroblock.o encoder/cabac.o encoder/cavlc.o encoder/encoder.o extras/getopt.o -Wl,-h,libx264.so.67 -lm -lpthread -s Text relocation remains referenced against symbol offset in file 0x6be common/mc.o 0x6d5 common/mc.o 0xbbe common/mc.o 0xbc5 common/mc.o ... __udivdi3 0x3809 common/set.o __udivdi3 0x3875 common/set.o __udivdi3 0x10cf encoder/macroblock.o __divdi3 0x17865 encoder/analyse.o __divdi3 0x1e9 encoder/set.o ld: fatal: relocations remain against allocatable but non-writable sections collect2: ld returned 1 exit status
then simply add “-mimpure-text -lrt” to your LDFLAGS.
A quick note to self, “gcc -shared” is better than “gcc -G”. The former tells gcc to build a shared object, which tells the linker (I suppose). The latter just tells the linker. Swapping a -shared for -G can fix the above issue, but creates other issues. Or something along those lines – I’m a bit hazy on this one.
This issue came about because I was getting errors when running a 64bit amd64 ffmpeg linked against libx264:
ld.so.1: ffmpeg: fatal: relocation error: R_AMD64_PC32: file /opt/ec/lib/amd64/libx264.so.67: symbol main: value 0x280018fc805 does not fit
The problem here was that I’d compiled libx264 with gcc -G instead of gcc -shared. However using -shared generated the “Text relocation remains against symbol” errors, which needed the “-mimpure-text -lrt” fix.