|
[Sponsors] |
May 4, 2001, 16:53 |
command to link fortran and c object
|
#1 |
Guest
Posts: n/a
|
Please help me what is the command in PC to link fortran and c object to create an executive file. I have a program written in fortran and c.
|
|
May 4, 2001, 18:22 |
Re: command to link fortran and c object
|
#2 |
Guest
Posts: n/a
|
The program that performs the operation is usually called a linker. On unix the command is "ld". It used to be "link" on PCDOS many years ago but I do not know how to perform the task by pointing and clicking at windows these days.
In addition, you will have to make sure all the Fortran and C libraries are linked in, the Fortran calling C and vice-versa naming conventions are followed (usually by adding underscores) and the convention for passing Fortran strings is followed (Fortran passes a pointer and a length, C just the pointer - usually the lengths are collected in order and placed at the end of the argument list). Mixed I/O can be a problem on some systems. Some systems prefer main to be in Fortran while others in C. The task is not wholly straightforward the first time and varies from system to system. |
|
May 5, 2001, 00:47 |
Re: command to link fortran and c object
|
#3 |
Guest
Posts: n/a
|
Yeah it's a pain in the ass. I had to do this once for visual C they recomended compiling individually then linking w/ visual C.
|
|
May 5, 2001, 04:27 |
Re: command to link fortran and c object
|
#4 |
Guest
Posts: n/a
|
To be able to link Fortran and C, watch the following rules during compilation. 1. For Fortran sources: use compiler switch to add underscore to all external names. 2. For Fortran sources: use compile switch to generate all external names in lowercase. 3. Make sure that you pass arguments by reference (pointers) between C and Fortran. 4. Avoid passing character strings between Fortran and C. If you must do it, read the documentation on how your compilers pass (and expect) characters in the parameter list. Besides the character string, its length should often be specified.
Now you can link the object files with the linker. DML |
|
May 5, 2001, 22:22 |
Re: command to link fortran and c object
|
#5 |
Guest
Posts: n/a
|
(1). I had looked into this kind of mixed language programming long time ago. But my conclusion was, try to avoid it by all means.
|
|
May 10, 2001, 07:06 |
Re: command to link fortran and c object
|
#6 |
Guest
Posts: n/a
|
Dear PHuang
After you had read all the messages in this thread try this (1) to compile your C source cc -c c_source.c (2) to link it with your fortran code f77 f_source.f c_source.o I agree with JCChien, avoid this Best whishes Kike |
|
May 17, 2001, 16:47 |
Re: command to link fortran and c object
|
#7 |
Guest
Posts: n/a
|
I can not avoid link c with fortran, because some cfd softwares are written in fortran and c. Normally they are linked by makefile in SGI. Can we create makefile for PC?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to link Fortran to Star-CD | lunar1984 | Siemens | 0 | September 13, 2011 11:16 |
How to link Fortran to Star-CD | lunar1984 | STAR-CD | 0 | September 13, 2011 11:02 |
CFX11 + Fortran compiler ? | Mohan | CFX | 20 | March 30, 2011 19:56 |
How to link my fortran program to UDFs? | Sam | FLUENT | 0 | October 29, 2008 04:57 |
link c++ with fortran object | Pao | Main CFD Forum | 0 | July 17, 2002 18:51 |