tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SOLUTION: Mixing C and Fortran
@ 1999-02-18 22:00 Tran, Duc-Chi
  0 siblings, 0 replies; only message in thread
From: Tran, Duc-Chi @ 1999-02-18 22:00 UTC (permalink / raw)
  To: tru64-unix-managers


Many thanks to Ms. Pamela Price and Mr. Burch Seymour and many others who  =
 =

promptly helped me.
Here is the solution:

(1) To compile the Fortran program, we need two options:
 -nofor=5fmain  (to indicate that the Fortran program is only a subroutine)=

 -assume nounderscore (so that the underscore is not added to the program  =
 =

name)

(2) To link using the linker directly (i.e. ld), we need to link with the  =
 =

object /usr/lib/cmplrs/cc/crt0.o=3b
 We also needs the options
 -lc  (for the C library libc.so or libc.a)
 -lfor  (for the Fortran library libfor.so or libfor.a)

Thank you again for the quick and effective help. I really appreaciate   =

it.

Duc-Chi Tran    (613) 951-3626    duc-chi.tran=40a.statcan.ca
Chief, Systems Support Section / Chef, section du soutien des syst=e8mes
Industry Measures =26 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=e9s, visitez   =

http://www.imad.statcan.ca

 -----Original Message-----
From: Tran, Duc-Chi
Sent: Thursday, February 18, 1999 9:26 AM
To: 'alpha-osf-managers'=3b 'Tran, Duc-Chi (old internet)'
Subject: Mixing C and Fortran

Hello Guru,

We need help badly and urgently. Please ALSO reply directly to my email   =

tranduc=40statcan.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 =22unresolved=22   =

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 =22Unresolved: printf=22

(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=40statcan.ca
Chief, Systems Support Section / Chef, section du soutien des syst=e8mes
Industry Measures =26 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=e9s, visitez   =

http://www.imad.statcan.ca  =

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-02-18 22:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-02-18 22:00 SOLUTION: Mixing C and Fortran Tran, Duc-Chi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox