From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2999 invoked by alias); 30 May 2011 18:53:02 -0000 Received: (qmail 2982 invoked by uid 22791); 30 May 2011 18:53:01 -0000 X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cdptpa-omtalb.mail.rr.com (HELO cdptpa-omtalb.mail.rr.com) (75.180.132.121) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 May 2011 18:52:45 +0000 X-Authority-Analysis: v=1.1 cv=8mDY8c80ZOa76EOwICuS+E2YRQjxDgO9xqUnRMONc7w= c=1 sm=0 a=kj9zAlcOel0A:10 a=P80jBE3D/ImvVFu4rR+tWA==:17 a=ayC55rCoAAAA:8 a=in--WAEBNQ4zKrsi5f4A:9 a=CjuIK1q_8ugA:10 a=P80jBE3D/ImvVFu4rR+tWA==:117 Received: from [75.80.130.152] ([75.80.130.152:51756] helo=[192.168.1.102]) by cdptpa-oedge03.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id F3/28-00666-C77E3ED4; Mon, 30 May 2011 18:52:45 +0000 From: coml2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Calling C from Fortran Date: Mon, 30 May 2011 22:42:00 -0000 Message-Id: To: gcc-help@gcc.gnu.org Mime-Version: 1.0 (Apple Message framework v1084) Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00430.txt.bz2 I am using an iMac running 10.6.7. I have a simple Fortran program that uses a simple C function and am workin= g 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 w= hich 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=3Di386 createfile_.c and got the error message: createfile_.c:1: error: CPU you selected does not support x86-64 instructio= n 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. =20 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.