public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: coml2 <coml2@san.rr.com>
To: gcc-help@gcc.gnu.org
Subject: Calling C from Fortran
Date: Mon, 30 May 2011 22:42:00 -0000	[thread overview]
Message-ID: <AF1A9A77-7F98-4FB5-B2D3-72A47BF57E87@san.rr.com> (raw)

I am using an iMac running 10.6.7.

I have a simple Fortran program that uses a simple C function and am working at the command line in Terminal.

I compile the C function with:

gcc -c createfile_.c

I then compile and link with:

gfortran test_file_handling.f90 createfile_.o

And get the error message:

ld: warning: in createfile_.o, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols:
  "_createfile_", referenced from:
      _MAIN__ in cc1JcwIf.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I then tried to define the architecture with:

gcc -c -mtune=i386 createfile_.c

and got the error message:

createfile_.c:1: error: CPU you selected does not support x86-64 instruction set

I tried other values of -mtune but have been unsuccessful.  I have searched help forums and Googled but have not found answers that seem applicable.

Please advise me regarding how to compile and link for using C functions in gfortran.
 
Hugh McCutchen
coml2@san.rr.com


Note:  gcc is a link that points to gcc-4.2 dated October 23, 2010.
Note:  I have appended an underscore to the C function name.

             reply	other threads:[~2011-05-30 18:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-30 22:42 coml2 [this message]
2011-05-31  5:44 ` Jonathan Wakely
2011-05-31  5:46   ` coml2
  -- strict thread matches above, loose matches on Subject: below --
2007-07-09 19:17 calling c++ from fortran Dima Sorkin

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=AF1A9A77-7F98-4FB5-B2D3-72A47BF57E87@san.rr.com \
    --to=coml2@san.rr.com \
    --cc=gcc-help@gcc.gnu.org \
    /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).