Darwin linker error "illegal text-relocation" with -shared

Thomas Koenig tkoenig@netcologne.de
Mon Apr 16 19:46:00 GMT 2018


OK, so I haven't played around with shared libraries a lot.

> In other words, the -c flag overrides the -shared flag.  This is not 
> what I want.  I want to create a shared library which is done by the 
> linker.

When I run "gfortran -shared foo.f90" on Linux, I get

/usr/bin/ld: /tmp/ccixEBK9.o: relocation R_X86_64_32 against `.rodata' 
can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: Fehler: ld gab 1 als Ende-Status zurück

whereas "gfortran -shared -fPIC foo.f90" works.

Is it advisable to compile a shared library without position-independent
code?



More information about the Fortran mailing list