I am trying to generate a shared library (libgenerated.so) using g++ . The shared library uses some functionality that comes from a third party static library (libmystatic.a). For which I am linking the static library with the shared library as :
g++ -shared -o libgenerated.so $(OBJ_FILES) -lmystatic
The above command returns the following relocation error for the static library:
relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
Which points out that the object files in the static library needs to be compiled with -fpic flag. I am unable to understand why creating a Windows dll using the same static library (compiled for windows without -fpic) works ? I am using x86_64-w64-mingw32-g++ for the Windows DLL.
Thoughts from experts....