Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Can't Get EXE To Find DLL

adamanthaea
Beginner
4,791 Views
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 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 or the debug folder results in a DFORRTD.DLL error instead of a missing retention.DLL error. 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. Any help would be greatly appreciated.
0 Kudos
23 Replies
Steven_L_Intel1
Employee
4,161 Views
You have built the DLL in a debug configuration. This introduces dependencies that don't allow for copying the DLL to a system where CVF is not installed. It is not clear to me if this is the issue, but it sounds as if it may be.
Rebuild as a Release configuration. If you are running on a system where CVF is not installed, download and install the Redistributables Kit.
The next thing to understand is how Windows searches for DLLs. It looks in the following locations (I may not have the order right):
  • Current directory
  • Directory containing the EXE that asked for the DLL (directly or indirectly)
  • Directories in PATH
  • Windows directory
  • Windows System directory

Note that when running in Developer Studio, the current directory is set to the project folder.

0 Kudos
adamanthaea
Beginner
4,161 Views
Thanks for the advice. I tried rebuilding the programs in Release mode. Still no go. The directories are:

C:... etention etention for the DLL and
C:... etention estretention for the EXE

with the DLLs and EXEs being in the release and debug subfolders. It's not a problem of getting it to work on a computer without CVF as I'm trying to execute the program from inside CVF. I tried placing the EXE folder as C:... etention etention estretention, but still no go.
0 Kudos
Steven_L_Intel1
Employee
4,161 Views
What is the complete and exact text of the error message?
0 Kudos
adamanthaea
Beginner
4,161 Views
The error message is:

This application has failed to start because retention.dll was not found. Re-installing the application may fix this problem.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
4,161 Views

Adam, I don't quite follow your setup, but here's a piece of advice about setting up the workspace in case of multiple projects -- it might help.

Jugoslav

0 Kudos
adamanthaea
Beginner
4,161 Views
It appears to be a run-time problem. It appears to compile and link correctly, as the error message doesn't appear until I try to execute the program.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
4,161 Views
I understand, and the suggestion in the link I referred to solves exactly that. The simplest way to develop a multiple-module solution is to ensure that the .exe and .dll's are in the same directory.
Jugoslav
0 Kudos
adamanthaea
Beginner
4,161 Views
Sorry. Didn't mean to be insulting. I'll give your procedure another shot.
0 Kudos
Steven_L_Intel1
Employee
4,161 Views
To help diagnose this, right click on the EXE and select View Dependencies. (If that option isn't there, let me know.) It will display all the DLLs your EXE is dependent on, and will indicate which ones can't be found.
Try putting your DLL in the same folder as the EXE.
0 Kudos
adamanthaea
Beginner
4,161 Views
Where should I click for the EXE? Bringing up the properties for the file I compile into an executable shows no dependencies. Right-clicking the actual executable file only brings up the normal Windows options. Is there a way to see the executable inside Dev Studio that I'm not seeing?
0 Kudos
g_f_thomas
Beginner
4,161 Views
Did you ever study the CVF DLL samples that come on the CD?
IMO it's the best place to start in trying to get into the hang of VS.

Ciao,
Gerry T.
0 Kudos
Steven_L_Intel1
Employee
4,161 Views
I don't mean inside Developer Studio. It could be that the Dependency Viewer is not available to you.
Try this instead. Download ftp://ftp.compaq.com/pub/products/fortran/vf/supp/loadtest.exe and put it in the same folder as your EXE. Open a command prompt window and CD to that folder. Then type:
loadtest yourexename.exe
What does it say?
0 Kudos
adamanthaea
Beginner
4,161 Views
Okay, I did that. The message is:

About to load: testretention.exe
Image: testretention.exe loaded OK
Done
0 Kudos
Steven_L_Intel1
Employee
4,161 Views
Ok. Are you still having problems running the program then?
0 Kudos
adamanthaea
Beginner
4,161 Views
Yes, it is still giving me the same missing DLL error message. I have the feeling I just missed some setting somewhere or something, but I can't track it down.
0 Kudos
Steven_L_Intel1
Employee
4,161 Views
Can you run the EXE by double-clicking on it? I can't see how LOADTEST would succeed but running it wouldn't.
0 Kudos
adamanthaea
Beginner
4,161 Views
No, it gives the same error message when executed either from Dev Studio or when I attempt to run it from Windows by double-clicking.
0 Kudos
Steven_L_Intel1
Employee
4,161 Views
I can't see how you would get the error when double-clicking, but LOADTEST worked ok.
Please try loadtest again but this time use the -d switch:
loadtest -d yourexe.exe
What does it say?
0 Kudos
adamanthaea
Beginner
4,161 Views


g.f.thomas wrote:
Did you ever study the CVF DLL samples that come on the CD?
IMO it's the best place to start in trying to get into the hang of VS.

Ciao,
Gerry T.




I have tried, but I cannot get the example files to compile properly. I'm not sure what I'm doing wrong, as I set up different workspaces for it and they still don't want to go. As far as I can tell, there is no tutorial documentation on how to use them.
0 Kudos
adamanthaea
Beginner
3,858 Views


sblionel wrote:
I can't see how you would get the error when double-clicking, but LOADTEST worked ok.
Please try loadtest again but this time use the -d switch:
loadtest -d yourexe.exe
What does it say?





Okay, now it doesn't work. The message in the command prompt is:

Image load at 400000 of: testretention.exe
DLL load at 77f50000 of: ntdll.dll
DLL load at 77e60000 of: C:WINDOWSsystem32kernel32.dll

And then it pops up a dialog box giving the familiar message:
This application failed to start because retention.dll was not found. Re-installing the application may fix this problem.

Then more error messages appear in the command prompt after closing the dialog box:

Exception: 0xc0000135 (3221225781.) - (Unable To Locate Component) This application has failed to start because %hs was not found. Re-installing the application may fix this problem.
Remote process terminated unexpectedly
Process exit status was: 0x79 (121.) - The semaphore timeout period has expired.
0 Kudos
Reply