Re: How to declare Fortran subroutine in C++ compiler??

New Message Reply Date view Thread view Subject view Author view

Hansong Zhang (zhangh++at++cs.unc.edu)
Sun, 22 Jun 1997 10:10:33 -0400 (EDT)


> Hello,
>
> I have a math subroutine which is written by Fortran. I use C++
> compiler to compile my Performer program. This math routine is part of my
> main(). When I compile this mixed language program, I get a unresolved "routine
> name" error.
>
> I declare this math routine as "extern int simmain()" in main.c. I
> compiled it by using f77, Fortran compiler. I put the simmain.o and -lF77,
> -lU77, -lI77,-lisam, -lm in the CC command line. I also tried to switch the
> location of simmain.o and main.o in the CC command line.
>
> Do I make any mistake? Or I forgot somethings else? I successed in
> compiling the C and Fortran mixed program. I realy need your help. I will very
> appreciate for you help. Have a nice day.
>
> p/s : my OS is IRIX 6.2
>

Try to declare the fortran function as
extern "C" {
 int simmain();
}
which prevents CC from generating signature for the function name and
making it differnt from the one in your fortran object file.

Besides (and if the above suggestion doesn't work), you can use the f2c
package to translate the fortran program to C. I used to use it for big
fortran math routines and it worked really well. f2c's available from
netlib.

hope this helps,
Hansong

-------------------------------------------------------------
Hansong Zhang \ zhangh++at++cs.unc.edu
Walkthrough Group \ http://www.cs.unc.edu/~zhangh
Department of Computer Science \ (919)962-1835 (O)
UNC-Chapel Hill \ (919)914-3973 (H)
-------------------------------------------------------------

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:29 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.