Re: Call fortran in C++ project



FlyVenus wrote:
Hi, All:
I plan to using a fortran 90 program in C++. I have no experience
about that, and I have some question about that.

1. I think I have two methods to using the fortran 90 program.
First, compile all the .f90 and .cpp to .obj, and link them. Second,
make the fortran 90 program to a dll, and call it in C++ project. I
want to know, which is better, and how I should do?

The second method is likely to involve less pain in terms of figuring out which linker to use, etc. You will still need to use the manual for your Fortran compiler to make sure that your Fortran routine in the dll is designed correctly to be called from C++.

2. In the fortran 90 program, there many Types. How can I using
them in C++.

See the manual for your Fortran compiler on mixed language programming. Possibly, all you will need to do is specify SEQUENCE and make sure that the TYPEs are compatible with C++ (i.e. no pointers or allocatables).
.



Relevant Pages

  • Re: Problem with DLL
    ... the Fortran compiler you are using but would assume that it generates dlls ... Fortran to be passed by reference. ... > thought to use a dll compiled from the first one. ... > integer function somma ...
    (comp.lang.fortran)
  • Re: C++ wrapper for a fortran77 program??
    ... If you want the Windows program to ... >fortran functions more easily. ... Now this is where your C++ wrapper might come in useful. ... will have to pass them in the form which your Fortran compiler expects, ...
    (comp.lang.fortran)
  • Re: Who uses clapack?
    ... been a FORTRAN compiler available for the target platforms that I was ... Even when a FORTRAN compiler is ... on what you are trying to accomplish with a new version of LAPACK. ...
    (comp.lang.c)
  • Re: Who uses clapack?
    ... been a FORTRAN compiler available for the target platforms that I was ... Even when a FORTRAN compiler is ... on what you are trying to accomplish with a new version of LAPACK. ...
    (comp.lang.fortran)
  • Re: Who uses clapack?
    ... been a FORTRAN compiler available for the target platforms that I was ... Even when a FORTRAN compiler is ... on what you are trying to accomplish with a new version of LAPACK. ...
    (sci.math.num-analysis)