- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried the following example, but didn't succeed.
I am not familar with how to call a dll. what is the problem with my calling?
some one can give some help? thanks!
!----- the main program calling a dll
PROGRAM DLLTEST
IMPLICIT NONE
INTERFACE
SUBROUTINE ARRAYTEST (sarray)
!DEC$ ATTRIBUTES DLLIMPORT:: ARRAYTEST
REAL(4) sarray(3, 7)
END SUBROUTINE ARRAYTEST
END INTERFACE
REAL(4) sarray(3,7)
CALL ARRAYTEST(sarray)
WRITE(12,*) sarray(:,:)
END PROGRAM DLLTEST
! --------- the program used for generating a dll
! ARRAYtest.f90
!
! FUNCTIONS/SUBROUTINES exported from ARRAYtest.dll:
! ARRAYtest - subroutine
!
SUBROUTINE ARRAYTEST(arr)
!DEC$ ATTRIBUTES DLLEXPORT :: ARRAYTEST
REAL(4) arr(3, 7)
INTEGER i, j
DO i = 1, 3
DO j = 1, 7
arr (i, j) = 11.0 * i + j
END DO
END DO
END SUBROUTINE
I am not familar with how to call a dll. what is the problem with my calling?
some one can give some help? thanks!
!----- the main program calling a dll
PROGRAM DLLTEST
IMPLICIT NONE
INTERFACE
SUBROUTINE ARRAYTEST (sarray)
!DEC$ ATTRIBUTES DLLIMPORT:: ARRAYTEST
REAL(4) sarray(3, 7)
END SUBROUTINE ARRAYTEST
END INTERFACE
REAL(4) sarray(3,7)
CALL ARRAYTEST(sarray)
WRITE(12,*) sarray(:,:)
END PROGRAM DLLTEST
! --------- the program used for generating a dll
! ARRAYtest.f90
!
! FUNCTIONS/SUBROUTINES exported from ARRAYtest.dll:
! ARRAYtest - subroutine
!
SUBROUTINE ARRAYTEST(arr)
!DEC$ ATTRIBUTES DLLEXPORT :: ARRAYTEST
REAL(4) arr(3, 7)
INTEGER i, j
DO i = 1, 3
DO j = 1, 7
arr (i, j) = 11.0 * i + j
END DO
END DO
END SUBROUTINE
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
when I compile the main program, the error is:
---
dlltest error LNK2019: unresolved external symbol __imp__ARRAYTEST referenced in function _MAIN__
dlltest fatal error LNK1120: 1 unresolved externals
---
it seems that the main program can't recognize the dll.
something wrong with my implementation?
---
dlltest error LNK2019: unresolved external symbol __imp__ARRAYTEST referenced in function _MAIN__
dlltest fatal error LNK1120: 1 unresolved externals
---
it seems that the main program can't recognize the dll.
something wrong with my implementation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you include the DLL's export library ARRAYTEST.LIB in your project when building your test program?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
solved,
it is successful when deleting " !DEC$ ATTRIBUTES DLLIMPORT:: ARRAYTEST".
it is successful when deleting " !DEC$ ATTRIBUTES DLLIMPORT:: ARRAYTEST".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then you are not linking to the DLL export library and probably not using the DLL.

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