What is the difference between `-fpic` and `-fPIC` gcc parameters?

Denilson Sá Maia picture Denilson Sá Maia · Aug 23, 2010 · Viewed 31.3k times · Source

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:

Answer

Anycorn picture Anycorn · Aug 23, 2010

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.