`-fpic`和`-fPIC` gcc参数有什么区别? [英] What is the difference between `-fpic` and `-fPIC` gcc parameters?

查看:203
本文介绍了`-fpic`和`-fPIC` gcc参数有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读过 gcc 手册页,但我仍然无法理解 -fpic -fPIC 。有人可以用简单明了的方式解释它吗?




相关问题:


解决方案

http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html



使用 -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:

解决方案

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参数有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆