Does one still need to use -fPIC when compiling with GCC?

前端 未结 5 1198
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-20 12:26

On gcc target machines, when one wanted to compile a shared library, one would need to specify -fpic or -fPIC to get things to work correcly. This is because by default absolute

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-20 13:07

    gcc targets a lot of platforms and architectures, and not all of them supports natively PIC like the x86 architecture does. In some cases, creating PIC means additional overhead, which may be undesired, and wether you want or need this is depending on your project and the platform you are targeting,.

提交回复
热议问题