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

11,814

Solution 1

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

Solution 2

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

Solution 3

Look for a GCC port to Windows, such as Mingw or GCW. Both those will create .obj files which can be linked to in Visual Studio. Or you could futz around and configure VS to invoke one of those command line compilers into the project. But since the code is relatively static, it might be a nice compile once and forget it task, hopefully.

Share:
11,814
Chad Mourning
Author by

Chad Mourning

Updated on June 10, 2022

Comments

  • Chad Mourning
    Chad Mourning almost 2 years

    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?