5

I have a bunch of static libraries in my hand, which all have two versions -- 32bit and 64bit. When I use these static libraries to compile into a shared library, weird things happened: 1. I use 64bit static libraries to compile a 64bit shared library, everything works well; 2. I use 32bit static libraries to compile a 32bit shared library, ld tells me that the [text section is not shareable].

So, I guess that 32bit static libraries don't use -fPIC flag, but my colleague tells me he dit add the flag. But I still suspect that, so is there a way to find out whether the static library do add the -fPIC flag. PS: I know use readelf or objdump may get some clues, but is there a better way?

Richard Shi
  • 53
  • 1
  • 4
  • 3
    possible duplicate of [How can I tell, with something like objdump, if an object file has been built with -fPIC?](http://stackoverflow.com/questions/1340402/how-can-i-tell-with-something-like-objdump-if-an-object-file-has-been-built-wi) – paulsm4 Sep 14 '15 at 09:07

1 Answers1

-1

I believe, if you are using linux, you can check out the output of file

file myLib.so
file myLib.a

The output should inform you if the library was compiled with -fPIC

neoaggelos
  • 632
  • 1
  • 4
  • 18