Mixing C and Fortran

From: Tran, Duc-Chi <tranduc_at_statcan.ca>
Date: Thu, 18 Feb 1999 09:46:00 -0500

Hello Guru,

We need help badly and urgently. Please ALSO reply directly to my email
tranduc_at_statcan.ca. Thank you.

I cannot create one single executable module from a C program calling a
Fortran 90 subroutine. The link-edit step fails with "unresolved"
reference. And it has to do with my not knowing how to use the flags of
the link-editor (ld) to link to supporting libraries of C and Fortran. To
validate my theorie, I did the following simple test:

(1) I created a simple C program (called test.c) with a printf statement.

(2) I complied and linked it with the cc command as belows and it worked
fine:
  cc -o test test.c

(3) I compiled and linked it SEPARATELY using only the cc command as
belows and it also worked:
  cc -o test.o test.c
  cc -o test test.o

(4) However, when I tried to compile it with cc and link it with ld, it
failed:
  cc -o test.o test.c
  ld -o test test.c
 And the message was "Unresolved: printf"

(5) I read the man pages of cc, F90, and ld very carefully and used all
sort of -L and -l flags, but could not solve the problem

Please help.

Duc-Chi Tran (613) 951-3626 tranduc_at_statcan.ca
Chief, Systems Support Section / Chef, section du soutien des systèmes
Industry Measures & Analysis Division / Division des mesures et de
l'analyse des industries
Statistics Canada / Statistique Canada
Visit our Web Site / Visitez notre site http://www.statcan.ca
For our employees, visit / Pour nos employés, visitez
http://www.imad.statcan.ca
Received on Thu Feb 18 1999 - 15:30:13 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:39 NZDT