- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a C++ dll and I want to call it in Visual Fortran, I have read an earlier thread about how to do.
But when the link it, i got the following error message:
error LNK2001: unresolved external symbol _GetSoftwareId
Debug/LoadExp1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Debug/LoadExp1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
My program is as follow:
program test
! Sample Fortran program that finds a dll library and calls
! a routine in it.
! Sample Fortran program that finds a dll library and calls
! a routine in it.
use kernel32
! Declare an interface block to the routine to be called.
interface
character Function GetSoftwareId()
!DEC$ ATTRIBUTES C, ALIAS:'_GetSoftwareId' :: GetSoftwareId
interface
character Function GetSoftwareId()
!DEC$ ATTRIBUTES C, ALIAS:'_GetSoftwareId' :: GetSoftwareId
end Function GetSoftwareId
end interface
integer p
pointer (q,rtn_vEMSJpn05)
logical status
character y
end interface
integer p
pointer (q,rtn_vEMSJpn05)
logical status
character y
! First, locate the dll and load it into memory
p = loadlibrary("vEMSJpn05.dll"C)
if (p == 0) then
type *, "Error occurred opening vEMSJpn05.dll"
type *, "Program aborting"
goto 1000
endif
! Set up a pointer to the routine of interest
q = getprocaddress(p, "GetSoftwareId@8"C)
q = getprocaddress(p, "GetSoftwareId@8"C)
if (q == 0) then
type *, "Error occurred finding GetOutputNames in vEMS"
type *, "Program aborting"
goto 1000
endif
type *, "Error occurred finding GetOutputNames in vEMS"
type *, "Program aborting"
goto 1000
endif
! the routine can be called
y = GetSoftwareId()
y = GetSoftwareId()
!
status = freelibrary(p)
type *, "freelibrary status was: ", status
1000continue
status = freelibrary(p)
type *, "freelibrary status was: ", status
1000continue
end program
Link Copied
0 Replies

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