using fortran lib in c++

P

Pawel_Iks

Suppose I have lib.o file with fortran functions (I know their names
and the lists of them arguments). How to write c++ program, which use
one of these functions, for example I want to use fortran function
which return int value and have as arguments two double numbers, and
how to compile it be g++ for example?
 
U

utab

Suppose I have lib.o file with fortran functions (I know their names
and the lists of them arguments). How to write c++ program, which use
one of these functions, for example I want to use fortran function
which return int value and have as arguments two double numbers, and
how to compile it be g++ for example?

Of course, you have to link that library. But there are some
differences(as far as I know) between F77 and F90 concerning the IO.
I, myself, use F77 on linux. I can link Lapack and C++ for instance
with g++.

You can also check the functions in the object file by the nm command.
See man nm

Also the function names most of the time take _ character, ex: for the
F77 functin foo, you have to call it as foo_ in C++ and make proper
extern declerations. These are the things I can quickly tell. But

Take a look at these pages and the similar ones

http://www.math.utah.edu/software/c-with-fortran.html

Mixed language programming and C++and Fortran or things like that.

HTH,
Umut
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top