问题描述
我已经阅读过 gcc
手册页,但我仍然无法理解 -fpic
和 -fPIC
。有人可以用简单明了的方式解释它吗?
相关问题:
-
使用-fPIC
或-fpic
来生成与位置无关的代码。是否使用-fPIC
或-fpic
生成与位置无关的代码是与目标相关的。-fPIC
选项总能正常工作,但可能会产生比-fpic
更大的代码(记住这是因为PIC是在更大的情况下,所以它可能会产生更多的代码)。使用-fpic
选项通常会生成更小更快的代码,但会有平台相关的限制,例如全局可见符号的数量或代码的大小。链接器会告诉你它是否适合创建共享库。如果有疑问,我会选择-fPIC
,因为它始终有效。I've already read the
gcc
manpage, but I still can't understand the difference between-fpic
and-fPIC
. Can someone explain it, in a very simple and clear way?Related questions:
- What does -fPIC mean when building a shared library?
- What, if any, are the implications of compiling objects with gcc -fPIC flag if they get used in executables?
解决方案http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
Use
-fPIC
or-fpic
to generate position independent code. Whether to use-fPIC
or-fpic
to generate position independent code is target-dependent. The-fPIC
choice always works, but may produce larger code than-fpic
(mnenomic to remember this is that PIC is in a larger case, so it may produce larger amounts of code). Using-fpic
option usually generates smaller and faster code, but will have platform-dependent limitations, such as the number of globally visible symbols or the size of the code. The linker will tell you whether it fits when you create the shared library. When in doubt, I choose-fPIC
, because it always works.这篇关于`-fpic`和`-fPIC` gcc参数有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!