This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Calling C from Fortran
- From: coml2 <coml2 at san dot rr dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 30 May 2011 11:52:44 -0700
- Subject: Calling C from Fortran
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.