By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,192 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,192 IT Pros & Developers. It's quick & easy.

using fortran lib in c++

P: n/a
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?

Aug 10 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Aug 10, 8:34 pm, Pawel_Iks <pawel.labed...@gmail.comwrote:
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

Aug 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.