Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran EXE Cannot Find Fortran DLL

Status
Not open for further replies.

adamanthaea

Programmer
May 13, 2004
4
0
0
US
I'm using CVF and am trying to get the basics of creating a DLL down so I can go on and do something bigger. I can get both the DLL and the EXE to compile properly. However, when I try to execute the program, it won't execute because it can't find the DLL. Here is my code for the program inside the DLL:

PROGRAM retention
END

SUBROUTINE VISC (tk, viscosity)
!DEC$ ATTRIBUTES DLLEXPORT :: VISC
REAL tk, viscosity
viscosity=(1.e-6*(5.6159426 + 0.053286909*tk))/(1 + 0.0002676519*tk)
END SUBROUTINE

And the code for the EXE is:

PROGRAM main
!DEC$ ATTRIBUTES DLLEXPORT :: VISC
REAL viscosity, tk
READ *,tk
CALL VISC (tk, viscosity)
PRINT *,tk,viscosity
STOP
END

I've tried just about everything I can think of. Manually moving the DLL to either the project folder, the debug folder, or the release folder results in a DFORRTD.DLL error instead of a missing retention.DLL error. I attempted to put the executable in a subfolder directly under the folder where the DLL is with no luck.

The error message is:
This application has failed to start because retention.dll was not found. Re-installing the application may fix this problem.

There is probably something incredibly stupid that I'm missing, but I cannot figure out what it is. Each program was coded in it's own little project folder. When I tried importing the projects into the same workspace, the DLL would compile properly but the EXE would not. Any help would be greatly appreciated.
 
Try adding the DLL's directory to your PATH.

If you have "depends" which comes with Visual Studio, run that, giving the name of the executable. It will tell you where it is looking for the DLLs and which ones it is picking up. Similar to LDD on Unix.
 
first of all the declaration in your main program should be:
[tt]!DEC$ ATTRIBUTES DLLIMPORT :: VISC[/tt]
secondly I think it is not necessary to create an empty program in your dll, you can include only exported functions and you need to add the import library created along with your dll to your EXE project to link them together (if not, you need to use the LoadLibrary and GetProcAddress to access to the dll). After successfull link, just put the dll and the executable in the same directory. This should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top