Ask Your Question
0

*-static library packages without -fPIC

asked 2012-07-29 14:01:48 -0500

Chinasaur gravatar image

updated 2012-07-29 14:02:50 -0500

Is it official policy that the *-static library packages are compiled without -fPIC? I've tried using libstdc++-static and libboost-static to statically link specific versions of these libraries into a shared module and neither of them had -fPIC so I had to start from scratch.

I realize there are some disadvantages to -fPIC, but are they significant? If the *-static packages cannot be used for the purpose outlined above, would there be any support for providing *-static-fpic or something like that?

I'm not sure how this is handled by other distros. I've noticed that the macports *-static packages seem to build with -fPIC.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-07-31 07:09:54 -0500

FranciscoD_ gravatar image

updated 2013-07-24 06:40:16 -0500

Static libraries are not built with -fPIC. As explained here, -fPIC implies: "position independent code"

"Creating a shared library is easy. First, create the object files that will go into the shared library using the gcc -fPIC or -fpic flag. The -fPIC and -fpic options enable ``position independent code'' generation, a requirement for shared libraries; see below for the differences. You pass the soname using the -Wl gcc option. The -Wl option passes options along to the linker (in this case the -soname linker option) - the commas after -Wl are not a typo, and you must not include unescaped whitespace in the option."

Therefore, the fedora packages that provide static libraries are not built with -fPIC.

This stack overflow answer will clarify further: http://stackoverflow.com/a/2649430

edit flag offensive delete link more

Comments

Thanks for info, but it doesn't seem to address the -fPIC question.

Chinasaur gravatar imageChinasaur ( 2013-07-23 17:57:01 -0500 )edit

The answer is dumb: there's no obvious logical inference that explains why fedora packages are built without -fPIC, except for the fact that there are pros and cons. The inability to use static libraries in shared code is a major limitation.

ceztko gravatar imageceztko ( 2018-05-08 03:45:57 -0500 )edit

Question Tools

Stats

Asked: 2012-07-29 14:01:48 -0500

Seen: 2,014 times

Last updated: Jul 24 '13