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

fortran dlls

fidand
Beginner
675 Views
I would like to find out if there is a way to create fortran dll that in turn will be called by VB 6.0. So far i have tried multiple different ways to accomplish this but it seems that i can not create a dll that will work just right. When the dll is called by Visual Basic 6.0 the following error message is displayed:

"Run Time Error 453"
Can't find DLL entry point _xadd@8 in .....

The fortran dll has one subroutine called xadd, which takes two parameters, both single in VB or real*4 in fortran and it outputs their result. I read numerous articles on this topic but had no luck so far. What am i doing wrong? Any ideas, comments or suggestions would be appreciated, thanks.
0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
675 Views
Both linker and run-time binding are case-sensitive. By default, CVF uppercases names in exported symbols and .objs, while VB expects lowercase. So, you can fix it either by aliasing the export on CVF side:

!DEC$ATTRIBUTES DLLEXPORT, DECORATE, ALIAS: "xadd":: XAdd
or
!DEC$ATTRIBUTES DLLEXPORT, ALIAS: "_xadd@8":: XAdd
(on older CVF versions)

or import on VB side:

Declare Sub XAdd(...) Lib "MyDll.dll" Alias "_XADD@8"

DUMPBIN command-line tool which comes with CVF can tell you a lot about contents of libs, objs and dlls.

Jugoslav
0 Kudos
fidand
Beginner
675 Views
Thanks for the pointer. At this time let me show you what code i have:

In fortran i wrote the following function which i turned to xadd.dll:

function xadd(a,b)
!DEC$ATTRIBUTES DLLEXPORT,ALIAS: "_xadd@8":: Xadd
xadd=a+b
return
end

In my VB 6.0 module global for the test project i wrote the following:

Public Declare Function xadd Lib "c:dllsxadd.dll" Alias "_xadd@8" (ByRef a As Single, ByRef b As Single) As Single

I do not know what to do beyond this point. I do not get any more errors, but my value from the xadd.dll is not being passed to VB. Any ideas or am i doing anything wrong again, thanks
0 Kudos
fidand
Beginner
675 Views
thanks i got it
0 Kudos
Reply