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

calling C++ dll in Fotran

vincent22
Beginner
291 Views
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.
My program is as follow:
program test
! 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
end Function GetSoftwareId
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)
if (q == 0) then
type *, "Error occurred finding GetOutputNames in vEMS"
type *, "Program aborting"
goto 1000
endif
! the routine can be called
y = GetSoftwareId()
!
status = freelibrary(p)
type *, "freelibrary status was: ", status
1000continue
end program
0 Kudos
0 Replies
Reply