public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ryan S. Elliott" <relliott@umn.edu>
To: Thomas Koenig <tkoenig@netcologne.de>
Cc: fortran@gcc.gnu.org
Subject: Re: Darwin linker error "illegal text-relocation" with -shared
Date: Mon, 16 Apr 2018 19:35:00 -0000	[thread overview]
Message-ID: <alpine.OSX.2.21.1804161433040.40373@er-10-128-80-101.wireless.umn.edu> (raw)
In-Reply-To: <dd809f00-65c1-954b-1c6e-cc8749e07739@netcologne.de>

[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]

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

  reply	other threads:[~2018-04-16 19:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 16:18 Ryan S. Elliott
2018-04-16 18:20 ` Thomas Koenig
2018-04-16 19:35   ` Ryan S. Elliott [this message]
2018-04-16 19:46     ` Thomas Koenig
2018-04-16 19:51       ` Ryan S. Elliott
2018-04-16 20:14         ` Steve Kargl
2018-04-16 21:09           ` Ryan S. Elliott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.21.1804161433040.40373@er-10-128-80-101.wireless.umn.edu \
    --to=relliott@umn.edu \
    --cc=fortran@gcc.gnu.org \
    --cc=tkoenig@netcologne.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).