Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling a Fortran .dll on Windows 7 (for free)?

My boss just asked me to integrate his bosses old Fortran code into a project (Java) I'm working on. The code was written in the 90s, so I imagine it'll still compile, so rather than re-write it, I'm hoping I can just call the functions from a .dll. I'm already calling some C .dlls, so I think I've got that part covered.

I've been doing some reading, and most of the articles talk about integrating the Intel Visual Fortran Compiler into Microsoft Visual Studio. We've got a university site license for Visual Studio, but it looks like the Intel Visual Fortran Compiler is in around the $700 range. I don't think my boss will go for that, so I'm looking for another option. I know Microsoft makes a lot of products freely available to students via Project Dreamspark, but I didn't see anything Fortran related.

I'm looking at some cygwin based options right now (g95, I think), but I'm looking for other ideas/options. Any ideas?

like image 886
Chad Mourning Avatar asked Feb 21 '12 23:02

Chad Mourning


2 Answers

I've used the gfortran (g95) compiler with the -shared flag to create DLLs. first compile the .for/.f90 files with:

gfortran -c myfile1.f90
gfortran -c myfile2.f90

then:

gfortran -shared -o mydll.dll myfile1.o myfile2.o
like image 182
bananafish Avatar answered Sep 17 '22 21:09

bananafish


MinGW will let you create a DLL that will work with your MS stuff.

like image 44
Ignacio Vazquez-Abrams Avatar answered Sep 21 '22 21:09

Ignacio Vazquez-Abrams