- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I try to implement a simple example (link) to import Fortran dll within Visual Fortran IDE. I compile and build the dll correctly , I guess. Also, in the main program , I introduce corresponding
.lib file's directory
(Properties -> Configuration Properties -> Linker -> General -> Additional Library Directories and type the path like "D:\ForDllTest\Debug)
and the lib file itself
(Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies and type the path like ForDLL.lib)
Also, I copy the corresponding DLL to the main project directory. When I compile the main program, it gives the following error.
Error 1 error LNK2019: unresolved external symbol __imp__ARRAYTEST referenced in function _MAIN__ FortTest.obj
I follow the official notes (Building Executables that Use DLLs). But, it doesn't work. Is there any mistake on setting the lib's location?
Would someone explain the reasons via Visual Fortran IDE (not from command window pls) ? I have checked lots of documents but until now none explain it clearly. Everybody mentions in a more complex way.
Thanks in advance...
DLL's Code:
! FortDLL.f90
!
subroutine FortDLL(arr)
! Expose subroutine FortDLL to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::FortDLL
REAL(4) arr(3, 7)
INTEGER i, j
PRINT *, "Fortran DLL is called ... "
DO i = 1, 3
DO j = 1, 7
arr (i, j) = 11.0 * i + j
PRINT *, "arr(i,j) = ", arr(i,j)
END DO
END DO
! Variables
PRINT *, "END of Fortran DLL ..."
! Body of FortDLL
end subroutine FortDLL
Main Program Code:
! FortTest.f90
program FortTest
implicit none
!DEC$ ATTRIBUTES DLLIMPORT:: ARRAYTEST
REAL(4) rarray (3,7)
CALL ARRAYTEST(rarray)
! Variables
! Body of FortTest
print *, 'Hello World'
end program FortTest
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Change the name of the exported subroutine to ARRAYTEST, to match what your DLL consumer program expects.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much,
What a big mistake I've done!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page