I am updating a 15 year old VB6 project that calls routines in a Ftn DLL. The DLL calls routines in a C++ static library. I have recently purchased the Intel Fortran compiler and have downloaded Visual Studio 2016. I have converted all of the VB, Ftn and C code. I did this by defining three, separate, Visual Studio projects: PcbPrg, PcbDll and PcbStl, a VB Windows forms project, a Ftn DLL project and a C static library project. I have been successful in calling the Ftn DLL routines (after about a week in “DLL Hell”).
My one remaining problem is getting the Ftn DLL routines to find/recognize the C static library. I have spent another week or longer reviewing the relevant information on the internet, including Steve Lionel’s discussions, including the one on August 10,2015, with other users having similar problems. I have also downloaded the Intel Reference Guide(2600 pages) and got a little bit lost and discouraged in that impressive document.
So here is a code snippet that shows where I am. Ignore the unusual line spacing and the occasional red colored underlines which evidently result from copying from MS Word.
************************************************************************
subroutine BITMAP_SIZE(bmpfile, bmpwidth, bmpheight, bmperror)
************************************************************************
implicit real*8 (a-h,o-z)
!DEC$ ATTRIBUTES DLLEXPORT :: BITMAP_SIZE
!DEC$ ATTRIBUTES ALIAS: 'BITMAP_SIZE' :: BITMAP_SIZE
interface
subroutine BmpSize(bmpfile,bmpwidth,bmpheight,bmperror)
!dec$ attributes C, alias:'BmpSize' :: BmpSize
!character (len=*) bmpfile
integer bmpwidth,bmpheight,bmperror
!dec$ attributes reference :: bmpfile
!dec$ attributes reference :: bmpwidth
!dec$ attributes reference :: bmpheight
!dec$ attributes reference :: bmperror
end subroutine BmpSize
end interface
character (len=*) bmpfile
integer bmpwidth, bmpheight, bmperror
bmperror=0
call BmpSize(bmpfile,bmpwidth,bmpheight,bmperror)
return
end
The VB calling routine successfully locates the Ftn called routine, BITMAP_SIZE, but throws an exception at the call to the C static library procedure, BmpSize,
call BmpSize(bmpfile,bmpwidth,bmpheight,bmperror)
The error message is,
error LNK2001: unresolved external symbol BmpSize
I guess this is not surprising, since I haven’t indicated, in the Visual Studio IDE for the Ftn project, where to find the C static library.
How do I do that?
I might add that I have an analogous problem trying to tie the VB project to the Ftn DLL project, using the IDE. I have taken the easy way out by putting the Ftn DLL file in the same folder as the VB exe file. This works fine but I am not able to run from within the IDE in either the debug or release configuration.
Finally, let me compliment Intel on the ease and efficiency with which your compiler ate up my old, fixed format, Fortran code and spit it out beautifully. I’ve probably gotten my $850 worth already, but if we can just get the DLL and the static library talking to each other, I would be doubly happy.
Thanks in advance,
Richard Sampson