- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I get this linker error. How can I get rid of __imp__ from __imp__SETFLUIDSDLL.
In the DLL the SETFLUIDSDLL is defined.
Thanks
Urs
1>------ Build started: Project: Console1, Configuration: Debug Win32 ------
1>Compiling with Intel(R) Visual Fortran Compiler 18.0.2.185 [IA-32]...
1>Console1.f90
1>Linking...
1>Console1.obj : error LNK2019: unresolved external symbol __imp__SETFLUIDSDLL referenced in function _MAIN__
1>Debug\Console1.exe : fatal error LNK1120: 1 unresolved externals
1>
The code is simple:
program Console1
implicit none
INTERFACE
SUBROUTINE SETFLUIDSdll(hfld,ierr, hFld_length)
!DEC$ ATTRIBUTES DLLIMPORT :: SETFLUIDSdll
!DEC$ ATTRIBUTES REFERENCE::hfld, ierr, hFld_length
CHARaCTER(*) hfld
INTEGER ierr, hFld_length
END SUBROUTINE SETFLUIDSdll
END INTERFACE
! Variables
CHARACTER (40) :: hfld
INTEGER ierr
INTEGER hFld_length
hfld = 'Test'
! Body of Console1
print *, 'Hello World'
call SETFLUIDSdll(hfld, ierr, hFld_length)
end program Console1
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem is really that you did not link to the export .LIB created when the DLL was linked. The __imp__ is part of the DLL resolution process.
Find that .LIB and add it to your project as if it were a source file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have added now the LIB file as source file, linking is working.
But I have another problem I get access violaitions and variable will be overwritten
iMass is set ot 1 at start, after the call of print '(F10.4)', Q, PX2
iMass is set to 0.
At the end I get to error
Run-Time Check Failure #2 - Stack around the variable '_RefPropTestCase$HX2' was corrupted.
What could be the reason?
Thanks
program RefPropTestCase
INTEGER :: IS
DOUBLE PRECISION DL, DV, Cv, Cp, W, W_H
DOUBLE PRECISION k_Vis, f_W
DOUBLE PRECISION :: aOutput(200), aOutputV(200), aOutputL(200), aOutputA(200)
DOUBLE PRECISION :: QX2, HX2, PX2, X2_V, X2_L, X2_A
character :: hFld*10000, hIn*255, hOut*255
integer :: iUnits, iMass, iFlag
double precision:: a, b
double precision:: Comp(20)
double precision :: Output(200)
character :: hUnits*255
integer :: iUCode
double precision :: CompL(20), CompV(20), CompL2(20), Q
integer :: ierr
character :: herr*255
hFld = 'C:\Program Files\MDT\CAE\REFPROP\FLUIDS\CO2.FLD'
CALL SETFLUIDSdll(hFld, ierr)
nComp = 1
HX2 = 412.243
PX2 = 4.6
Q = 0.95
iFlag = 0
iUnits = 2
IS = 1
iMass = 1
! print '(F9.4)', aOutput(1:4)
! print '(F9.4)', PX2, HX2
! print '(F9.4)', CompL(1), CompL(2), CompV(1), CompL2(1)
! print '(F9.4)', Q
IF (nComp.EQ.1) THEN
hIn = 'PH'
hOut = 'M,V,T'
CALL REFPROPdll(hFld, hIn, hOut, &
iUnits, iMass, iFlag, PX2, HX2, &
Comp, aOutput, hUnits, iUCode, &
CompL, CompV, CompL2, Q, ierr, herr)
IF (Q.GE.0.0.AND.Q.LT.1.0) THEN
X2_V = Q
X2_L = 1-Q
X2_A = 0
print '(F10.4)', Q, PX2
! Daten der gesättigten Flüssigkeit
QX2 = 0.0
hIn = 'PQ'
hOut = 'M,V,H,S,VIS,Z,CP/CV,W'
CALL REFPROPdll(hFld, hIn, hOut, &
iUnits, iMass, iFlag, PX2, QX2, &
Comp, aOutputL, hUnits, iUCode, &
CompL, CompV, CompL2, Q, ierr, herr)
! IS = ISX
! Daten vom gesättigen Dampf
QX2 = 1.0
CALL REFPROPdll(hFld, hIn, hOut, &
iUnits, iMass, iFlag, PX2, QX2, &
Comp, aOutputV, hUnits, iUCode, &
CompL, CompV, CompL2, Q, ierr, herr)
! IS = ISX
! Dummy-Werte in den Output für die Wasserphase einfügen
aOutputA(2:8) = 1
! Berechnen der Homogenen Daten und belegen von aOutput
! Molekulargewicht [kg/kmol]
aOutput(1) = aOutputV(1)
! spezifisches Volumen [m3/kg]
aOutput(2) = HOMOGEN_PROP(X2_V,aOutputV(2), &
X2_L,aOutputL(2), &
X2_A,aOutputA(2))
end if
end if
end program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are plenty of possible causes for such a corruption - violation of array bounds is one, a wrong argument list is another. Is your routine REFPROPdll part of a module or is its interface explicitly defined via an interface block? It does not look like it. The first thing to do is check the call to that routine - I advise using modules and interface blocks so that you can leave it to the compiler. Then another thing is to turn on all runtime checks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I am trying this interface method
subroutine REFPROPdll(hFld,hIn,hOut,iUnits,iMass,iFlag,a,b,z,Output,hUnits,iUCode,x,y,x3,q,ierr,herr)
!DIR$ ATTRIBUTES DLLIMPORT, DECORATE
!DIR$ ATTRIBUTES C, REFERENCE::REFPROPdll
character hFld*10000,hIn*255,hOut*255,hUnits*255,herr*255
integer iUnits,iMass,iFlag,iUCode,ierr
double precision a,b,q
double precision z(20),Output(200),x(20),y(20),x3(20)
end subroutine
i get the error unresolved external symbol _refpropdll.
Because of other old dll I have to set the
Calling Conventiion to CVF and the Name Case Interpretation to Default.
I do not know how the to specifiy the symbol to REFPROPdll. This is the way
how it it exported in the dll.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The CVF convention includes "STDCALL" if I am not mistaken and that is responsible for a name in capitals and a suffix counting the number of bytes in the argument list. IIRC, that comes in place of the keyword "C"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wagner_Urs
This may help you.
Include Refprop dll in Fortran · Issue #164 · usnistgov/REFPROP-wrappers · GitHub
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page