如何使用 -fPIC 重新编译

How to recompile with -fPIC(如何使用 -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 重新编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Prevent class inheritance in C++(防止 C++ 中的类继承)
Why should I declare a virtual destructor for an abstract class in C++?(为什么要在 C++ 中为抽象类声明虚拟析构函数?)
Why is Default constructor called in virtual inheritance?(为什么在虚拟继承中调用默认构造函数?)
C++ cast to derived class(C++ 转换为派生类)
C++ virtual function return type(C++虚函数返回类型)
Is there any real risk to deriving from the C++ STL containers?(从 C++ STL 容器派生是否有任何真正的风险?)