- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the past I have written Fortran software, compiled it into a DLL using Compaq Visual Fortran and been able to call the DLL from Microsoft Excel without any problems. I would now like to be able to do the same thing again but using Intel Visual Fortran (Microsoft Visual Studio) to compile the DLL.
The software consists of about 40 subroutines, of which 6 are to be "visible" from the DLL. A potential complication (I think) is that one of these visible 6 subroutines is also called from within another one of the visible 6.
After reading other documentation and threads, I have replaced the basic
!DEC$ ATTRIBUTES DLLEXPORT :: SUBROUTINE1
statement, used when compiling using Compaq Visual Fortran, with the statement
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS:"SUBROUTINE1" :: SUBROUTINE1,
and also included statements such as
!DEC$ ATTRIBUTES REFERENCE :: PARAMETER1
where there are non-array output parameters.
When I try to compile using Intel Visual Fortran, I get an error message of the form
error LNK2019: unresolved external symbol _SUBROUTINE2 referenced in function SUBROUTINE1.
I'm wondering if anyone has tried to do something similar and has some advice or if there is simply something obvious that I am missing. (I don't have any problems creating a DLL that can be called from Excel in the case where there is no interaction between the subroutines.)
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To fix this, add:
!DEC$ ATTRIBUTES STDCALL, REFERENCE, ALIAS:"SUBROUTINE1" :: SUBROUTINE1
in the sources where you call SUBROUTINE1. Add similar directives for other internal routines you call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help, Steve. Where appropriate I added the statement as you suggested and was able to compile the software successfully.
I then encountered another problem (for which I haven't been able to find a solution despite quite a lot of searching). In Microsoft Excel, when I press the button to call the VBA code, no results are written to the spreadsheet. If I place a breakpoint in the VBA code and step through it, the DLL is called successfully and the expected results are written to the spreadsheet.
When I run Dependency Walker on the DLL, IESHIMS.DLL and WER.DLL are reported as being missing, but from reading other threads Isuspect thatthis is not a major problem.
Have you previously encountered this difference between calling a DLL in Microsoft Excel "normally" and in debug mode?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have not seen an issue with Excel calling a Fortran DLL in debug mode.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page