- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I've been testing a simple *.dll creation in IFC9:
subroutine test_dll()
! Expose subroutine test_dll to users of this DLL
!DEC$ ATTRIBUTES DLLEXPORT::test
INTEGER I
DO 2 I=1,100
WRITE (*,8)I
8 FORMAT(I4)
2 CONTINUE
end subroutine test_dll
compiled with the following options:
/nologo /Zi /Od /module:"$(INTDIR)/" /object:"$(INTDIR)/" /traceback /check:bounds /libs:dll /threads /dbglibs /c
/dll
then I've tried to call the sub in a VB.net project:
Declare Sub test Lib "test_dll" ()
Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
Call test()
End Sub
End Class
Then I got a message saying that it can't find the entry point test in the test.dll
Obviously it finds teh dll file but not the entry point.
What am I doing wrong?
Many thanX for your help,
Jean
I've been testing a simple *.dll creation in IFC9:
subroutine test_dll()
! Expose subroutine test_dll to users of this DLL
!DEC$ ATTRIBUTES DLLEXPORT::test
INTEGER I
DO 2 I=1,100
WRITE (*,8)I
8 FORMAT(I4)
2 CONTINUE
end subroutine test_dll
compiled with the following options:
/nologo /Zi /Od /module:"$(INTDIR)/" /object:"$(INTDIR)/" /traceback /check:bounds /libs:dll /threads /dbglibs /c
/dll
then I've tried to call the sub in a VB.net project:
Declare Sub test Lib "test_dll" ()
Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
Call test()
End Sub
End Class
Then I got a message saying that it can't find the entry point test in the test.dll
Obviously it finds teh dll file but not the entry point.
What am I doing wrong?
Many thanX for your help,
Jean
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To call a VF dll from VB, you have to use STDCALL calling convention (AFAIK VB doesn't support IVF's default __cdecl). Either compile the dll with /iface:cvf, or add STDCALL attribute. (Also note that STDCALL implies ByVal, but /iface:cvf implies ByRef).
Also, you have to export the symbol "test" undecorated. Add ALIAS:"test" to !DEC$ATTRIBUTES.
Jugoslav
Also, you have to export the symbol "test" undecorated. Add ALIAS:"test" to !DEC$ATTRIBUTES.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Several problems here. Start the routine this way:
1. Routine name didn't match
2. VB wants STDCALL as the calling mechanism
3. VB is case-sensitive and looks for the exact name, not wanting the STDCALL name decoration.
subroutine test()
! Expose subroutine test to users of this DLL
!DEC$ ATTRIBUTES STDCALL,REFERENCE,ALIAS:"test",DLLEXPORT::test
1. Routine name didn't match
2. VB wants STDCALL as the calling mechanism
3. VB is case-sensitive and looks for the exact name, not wanting the STDCALL name decoration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jugoslav,
ThanX for your quick reply.
I'm afraid to say that I'm quite a beginner and do not follow completely your answer.
Could you please provide me a detailed example how to do it?
Many thanks,
Cheers,
Jean
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This should work (but untested):
Jugoslav<.a>
subroutine test_dll(j)
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, ALIAS:"test_dll":: test_dll
!DEC$ ATTRIBUTES REFERENCE:: j
INTEGER:: j
INTEGER I
J = 0
DO I=1,100
J = J + i
END DO
end subroutine test_dll
======================================================
Declare Sub test_dll Lib "test_dll" (ByRef j As Integer)
Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
Dim J As Integer 'Or Long, depending on VB version
Call test_dll(J)
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll try it out...
Many thanX
Jean
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page