gccpositionfpic

Is there a way to determine that a .a or .so library has been compiled as position indepenent code?


I am getting a linking error when compiling the numpy library against lapack indicating I need to compile lapack with -fPIC. I thought I had done just that. Is there a way to determine that the produced lapack library is position independent?


Solution

  • In general, you have no way of knowing:

    $ cat a.c
    int foo(int x) { return x+1; }
    $ gcc -fno-pic a.c -c -o nopic.o
    $ gcc -fPIC a.c -c -o pic.o   
    $ cmp pic.o nopic.o 
    $ cmp pic.o nopic.o && echo Identical
    Identical