About PIC on non-library objects

DervishD raul@pleyades.net
Thu Jul 18 02:14:00 GMT 2002


    Hello all :))

    I have a doubt about using -fPIC (on Linux, mainly). The question
is: can I use -fPIC on ALL objects? I already know that I'll need PIC
objects when building a shared library but, will I need them too (or
will it cause any harm) when building an static library?

    I've made a shared library and its static counterpart using PIC
objects on both libes, and it seems to work OK, but the code is fake,
just for testing the linkage, and I don't know if it will work
always.

    Moreover, for simplifying the makefiles, it would be great if I
could compile the 'main*.c' sources (they just contain the 'main()'
function and calls to the libraries functions) with PIC too. Would it
cause any harm?.

    Oh, I almost forgot: this is just for C, no C++ involved ;)

    Thanks a lot for your answers :) (Please CC me, I'm not on the
list)

    Raúl



More information about the Gcc-help mailing list