Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

Compiling with -fPIC for shared and static object

riveraro
Beginner
1,758 Views
Hi

I want to build a library *.a that can be used for building share libraries and consequently link these with dynamic executables.

I want to use the same *.a library to build other static object as well.

I compiled the objects that go within this *.a library with -fPIC option (packet afterwards with ar ). As a result the objects that are inside *.a are suitable for creating share objects

the question : Are the object inside of *.a suitable for building static object ? I did a test case and It seems to be working . Any Recommendation or observation , am I getting away from the cannonical form? or it is indifferent

Regards

riveraro
0 Kudos
2 Replies
TimP
Honored Contributor III
1,758 Views
There are several good on-line references, e.g.
http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html
As far as I could see, the only likely loss with -fPIC in static libraries is the possible increase in code size and function call overhead.
0 Kudos
riveraro
Beginner
1,758 Views
Thanks for the answer
I did read the article , specifically I couldn't find the answer , but googling for it , it seems to be not such a good idea .


Maybe more details :

I am able to build shared libraries with a normal *.a (this library is given and i can't rebuild it myself )

as expected if I build my objects and I try to link with the library *.a i get the error "the *.a was not compile with -fPIC cannot buld shared objects...."

the work around I figured out was , I compiled all object with the normal *.a library and -fPIC option
I have a collection of objects. I simply linked the objects to form the shared library and it works. If the performance is Ok , that is the question ?




0 Kudos
Reply