I would like to create a shared library with gfortran, linking it to the static version of libgfortran for mobility reasons. Unfortunately, I am unable to relate different objects accordingly. I already found some posts on a similar problem, but I could not figure out how to fix this problem.
My source files are compiled with the -fPIC flag. When I try to associate objects with the -shared and -static-libgfortran , I get the following error message:
gfortran -shared -static-libgfortran file1.o file2.o file3.o -o "mynewlib.so" /usr/bin/ld: ../lib64/libgfortran.a(error.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC ../lib64/libgfortran.a: could not read symbols: Bad value collect2: ld returned 1 exit status
I am using gfortran 4.6.3, which I combined from my server. The installation went smoothly and I did not change the standard configuration. I found on older posts that the compiler should be configured using --with-pic , but this flag is not mentioned in the GCC manual.
Does the problem arise from the compiler or from how I try to link different objects? Any idea how I can fix this?
Thanks in advance for your help!
remek
source share