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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值