Darwin linker error "illegal text-relocation" with -shared
Ryan S. Elliott
relliott@umn.edu
Mon Apr 16 19:35:00 GMT 2018
On Mon, 16 Apr 2018, Thomas Koenig wrote:
> Hello Ryan,
>
>> foo.f90
>> ----------------------------------------------
>> module foo contains
>> Â subroutine bar
>> Â Â Â use, intrinsic :: iso_c_binding
>> Â Â Â call gee(c_funloc(gee))
>> Â end subroutine
>> Â subroutine gee(f) bind(c)
>> Â Â Â use, intrinsic :: iso_c_binding
>> Â Â Â type(c_funptr) :: f
>> Â end subroutine
>> end module foo
>> ----------------------------------------------
>>
>> $ gfortran-7 -shared foo.f90
>
> You are invoking gfortran without the "-c" option, so it expects to
> generate an executable. Yet, you specify "-shared", which only makes
> sense for a library, and your source code does not contain a main
> program.
>
> What happens if you run
>
> "gfortran -c -shared foo.f90" ?
Hello, Thanks for your message.
Your suggestion does not generate an error, but only because it does not invoke
the linker in order to create a shared library. It just creates a .mod and .o
file.
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.
Ryan
More information about the Fortran
mailing list