ffmpeg编译报错

/usr/bin/ld: libavcodec/mqc.o: relocation R_X86_64_32 against `.rodata’ can not be used when making a shared object; recompile with -fPIC
libavcodec/mqc.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [libavcodec/libavcodec.so.57] Error 1

解决思路:

fPIC的全称是 Position Independent Code, 用于生成位置无关代码。
-fPIC:表示编译为位置独立的代码

ffmpeg-3.4.2/使用gcc来编译静态依赖库,需要在ffmpeg-3.4.2/ffbuild下面,编辑 config.mak

在CPPFLAGS中添加-fPIC字符串。具体如下:

CPPFLAGS= -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -I$(SRC_PATH)/compat/atomics/gcc -DZLIB_CONST
CFLAGS= -std=c11 -fomit-frame-pointer -fPIC -pthread -I/root/ffmpeg_build/include/SDL2 -D_REENTRANT -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized

你可能感兴趣的:(杂七杂八)