Reputation: 63
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?
Upvotes: 6
Views: 3108
Reputation: 640
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
Upvotes: -1