How to recompile with -fPIC(如何使用 -fPIC 重新编译)
问题描述
我试图在我的 ARM Ubuntu 上按照这个指南重新安装我的 ffmpeg机器.不幸的是,当我编译一个使用这个库的程序时,我得到了以下失败:
I was trying to reinstall my ffmpeg, following this guide, on my ARM Ubuntu machine. Unfortunately, when I compile a program which uses this lib I get the following failure:
/usr/bin/ld: /usr/local/lib/libavcodec.a(amrnbdec.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
现在我想用 -fPIC 重新编译它,就像编译器建议的那样,但我不知道如何.任何帮助表示赞赏.
Now I would like to recompile it with -fPIC like the compiler is suggesting but I have no idea how. Any help is appreciated.
推荐答案
简而言之,该错误意味着您不能使用静态库与动态库链接.正确的做法是把一个libavcodec编译成一个.so而不是.a,这样另一个.so> 您尝试构建的库可以很好地链接.
Briefly, the error means that you can't use a static library to be linked w/ a dynamic one.
The correct way is to have a libavcodec compiled into a .so instead of .a, so the other .so library you are trying to build will link well.
这样做的最短方法是在 ./configure 选项中添加 --enable-shared.或者您甚至可以尝试完全禁用共享(或静态)库……您选择适合您的库!
The shortest way to do so is to add --enable-shared at ./configure options. Or even you may try to disable shared (or static) libraries at all... you choose what is suitable for you!
这篇关于如何使用 -fPIC 重新编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 -fPIC 重新编译
基础教程推荐
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- c++ STL设置差异 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
