473,382 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

using fortran lib in c++

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
1 1822
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Markus Faust | last post by:
Hi, I'm trying to link Fortran files generated with “Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update B)” under “Enthought Edition build 1028, Python 2.3 (#46, Aug 11 2003,...
4
by: NM | last post by:
Hello All I am writing some progam that involves both C++ and Fortran. Some of the existing code is in Fortran. The main program will be in C++ and it will call some Fortran subroutine. All the...
6
by: Santosh | last post by:
Hello all, I am trying to interface c++ and fortran, the fortran code is already there and I was successful in calling the subroutines and functions, but was not able to send the fortran module...
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of the array in fortran code, do some filling up of...
2
by: NM | last post by:
Hello all, I am supposed to do some mixed programming with c++ and fortran. I was succeeful in exchanging the 2D arrays from fortran to c++ and the other way, but was unable to that same with...
2
by: Pavan Zope | last post by:
Hello I am facing a weired problem in calling a fortran routine from c. The fortran function in question is like this:- subroutine fortran_fun(idtab, nx, x, nf, nh, nhd, info, rinfo, fa, ga,...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
2
by: Ray J. | last post by:
I have a C++ program written and compiled on Solaris 8 with gcc. With gcc lets me compile fortran code along with the C++ program to be able to call the fortran code as a subroutine. The...
4
by: sara_patty | last post by:
fortran command for c command strcopy(infile, argv)
4
by: rudra | last post by:
dear friends, i am new to C/C++ and i need to call ranlux routine from my fortran code...here is a toy fortran code, which is calling the C++ program that uses ranlux(its actually C code given in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.