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

Intel Fortran Call vc dynamic library

ollehyas
Beginner
356 Views
I build dynamic library with vs2008 like this

extern "C" _declspec(dllexport) void _stdcall ADD_d(int*,int*);
void _stdcall ADD_d(int*A,int*B)
{
B=A+10;
}

then call this function in the fortran like this

!DEC$ ATTRIBUTES DLLIMPORT :: ADD

integer A,B

A=10
call ADD_d(A,B)

but linked using intel fortran, error occur ike this

_ADD_D cannot resovled

can anyone tell me how to fix the problem?



0 Kudos
5 Replies
DavidWhite
Valued Contributor II
356 Views
I suggest you look at the mixed language section of the documentation - you probably need to use STDCALL in the Fortran DLL declarations. Also, you need to look at what symbols the DLL is exporting (suggest you use dependency walker from dependencywalker.com). You may need an Alias to correctly decorate the name expected by Fortran - both case and the underscores are significant.

David
0 Kudos
ollehyas
Beginner
356 Views

anyone can give me more obvious answer?

0 Kudos
DavidWhite
Valued Contributor II
356 Views
0 Kudos
IanH
Honored Contributor II
356 Views
Follow David's advice and (read the documentation then) add the STDCALL and ALIAS attributes (and fix the subroutine name typo?). To do this you'll also need an interface block.

[fortran]INTERFACE
  SUBROUTINE ADD_d(a, b)
  ! Be mindful of line length in fixed form
  !DEC$ ATTRIBUTES DLLIMPORT, STDCALL, DECORATE, ALIAS:'ADD_d' :: ADD_d
    IMPLICIT NONE
    INTEGER :: a, b
  END SUBROUTINE ADD_d
END INTERFACE
[/fortran]

Is there a reason that you are using STDCALL? If not, then consider using the Fortran 2003 C interoperability feature of Intel Fortran.

0 Kudos
Arjen_Markus
Honored Contributor I
356 Views
The actual routine is called ADD_d, but your dllimport statement refers to ADD.

Regards,

Arjen
0 Kudos
Reply