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

IVF exe calling IVF dll

lloydchriswilson
Beginner
301 Views

I created a IVF DLL that is successfully being called from VB.Net. I want to create a small stub IVF console EXE that also calls the same DLL and am having some difficulty.

I have two IVF projects in a single solution; the EXE "depends" on the DLL, so no explicit link to the .LIB file is needed. I can successfully reference and call a DLL routine that has no arguments, but when trying to call one with arguments, get the error:

Error13 error LNK2019: unresolved external symbol _RIV1Q_GETVARCOUNT referenced in function _MAIN__Riv1Q_EXE.obj

I ran DUMPBIN on the DLL LIB file and get this:


Microsoft COFF/PE Dumper Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file riv1q.lib

File Type: LIBRARY

Exports

ordinal name

Riv1Q_Cancel
Riv1Q_Compute
Riv1Q_GetData
Riv1Q_GetErrMsg
Riv1Q_GetProgress
Riv1Q_GetVarCount
Riv1Q_GetVarName
Riv1Q_GetVarUnits
Riv1Q_Initialize

Summary

C0 .debug$S
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
A .idata$6

My DLL routine looks like this:

[vb]	SUBROUTINE Riv1Q_GetVarCount(VarCount)
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL :: Riv1Q_GetVarCount
!DEC$ ATTRIBUTES ALIAS:'Riv1Q_GetVarCount' :: Riv1Q_GetVarCount
	INCLUDE 'Riv1Q.inc'
	INTEGER, INTENT(OUT) :: VarCount(3)
!DEC$ ATTRIBUTES REFERENCE :: VarCount
[/vb]

My call to that routine looks like this:

[vb]!DEC$ ATTRIBUTES DLLIMPORT, C, ALIAS:'Riv1Q_GetVarCount' :: RIV1Q_GETVARCOUNT

      INTEGER VarCount(3)
      call riv1q_getvarcount(varcount)
[/vb]
[vb]The DUMPBIN output appears that it isn't really STDCALL, but changing the attributes to C doesn't solve the problem.[/vb]
[vb]Thanks in advance for your assistance.[/vb]
[vb][/vb]
[vb]Chris[/vb]
0 Kudos
3 Replies
Steven_L_Intel1
Employee
301 Views

Because you have the ALIAS, the external name does not change with C or STDCALL. However, these MUST be consistent or else you'll have run-time problems.

Is your main program source fixed-form, with a file type of .F or .FOR? I think you'll find that the directive you added in the main program extends past column 72 and therefore doesn't have the effect you intend. You may need to split this into two or more lines as you do in the DLL routine.

0 Kudos
lloydchriswilson
Beginner
301 Views
That was the problem, of course. I didn't think of the $DEC statements being like normal Fortran statements with the 72 column limitation. Thanks for your quick response!
By way of explanation, with other Fortran compilers, it was so incredibly difficult to make DLL calls, that I assumed the same for IVF and completely missed the obvious. I've only been using it for 1 day, but am very pleased--especially with the tech support!
Chris
0 Kudos
Steven_L_Intel1
Employee
301 Views

That's what I like to hear. Glad to have been of help.

0 Kudos
Reply