
-----------------------------------
FileFantasy
Fri Jun 27, 2008 10:21 am

Need help compiling mixed C++ / Fortran code with MinGW
-----------------------------------
Hey there,

I have a subroutine written in Fortran (sub.f), and my main () is in the C++ (main.cpp), calling the Fortran subroutine.

There's no other files, only sub.f and main.cpp

The code in C++ that calls the Fortran subroutine should be written correctly, I'm just wondering how to compile this program using MinGW to run it as an executable.

If it is not possible with MinGW's g++ or g77, can someone direct me to a compiler that can accomplish this task? Thanks.

---

Edit: Sorry forgot to add - this is on Vista (sadly), working in cmd.exe (MinGW is properly set up and g++ & g77 both work)

-----------------------------------
btiffin
Fri Jun 27, 2008 12:14 pm

RE:Need help compiling mixed C++ / Fortran code with MinGW
-----------------------------------
Haven't looked through it, but try
http://www.yolinux.com/TUTORIALS/LinuxTutorialMixingFortranAndC.html

and see if you can glean any MinGW hints from it.  Should match fairly closely.

Cheers

-----------------------------------
FileFantasy
Fri Jun 27, 2008 1:29 pm

Mixed language programming using C++ and FORTRAN 77
-----------------------------------
K I found an answer. Given:

main.cpp
#include 
using namespace std;

extern "C" 
{
    int sub1_();
}
main()
{
	cout 