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

Fortran main program call DLL

shun
Beginner
212 Views
I failed to call DLL from Compaq Fortran. If you have the experience, please give me some instructions and some program examples.
Thanks.
Shun
0 Kudos
1 Reply
Lorri_M_Intel
Employee
212 Views

Hi-

You don't say what sort of problems you're having, so I'll make a few guesses.

If you're getting unresolved references to the routines in the DLL at link-time, check that you are linking against the export library for the DLL. If there is no export library, you either have to use LoadLibrary/GetProcAddress to dynamically load the DLL and locate the routine address, or create an export library yourself.

If you're getting unresolved references to the routines in the DLL at link time and you know you are linking against the export library, make sure the names match. CVF uses stdcall by default; if this is a library of C routines, the calling standard may be quite different. I am assuming this is your problem.

This second case is the interesting one. If the problem is a mismatch between Fortran and C, I highly recommend that you look in the Programmer's Guide, in the chapter on Programming with Mixed Languages. This will cover what you need to know to hook Fortran to C.

Also, there are many samples on the kit, but they are not installed by default. If you did not do a custom installation and install the samples, go back and do that now.It will create a directory named something like:

c:program filesmicrosoft visual studiodf98samples

(assuming you've used the default locations. Your system may be different.)

In that samples area you'll find a couple of DLL-specific ones, for doing unusual things with DLL (like sharing common code, or dealing with inter-dependent DLLs). What's probably more interesting though, is the MIXLANG subdirectory. That has many examples of Fortran + C.

Also on the kit is a set of "unsupported" tools. If you open the CD (rather than letting autorun start the installation) you'll find a directory X86USUPPORTMISC containing miscellaneous "useful" tools, and one of these tools is "makilib.exe". That can be used to help you make an import library from an existing DLL, in case I was mistaken about what your problem was, and you didn't have an import library.

I hope this helps,

- Lorri

0 Kudos
Reply