- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a c++ .dll I didn't write, and I want to call the functions in the .dll from my Fortran program. I've seen a few different methods, but can't seem to get anything to work. Code would look something like:
!DEC$ ATTRIBUTES DLLIMPORT, STDCALL, ALIAS : '_AirPTBW' :: AIRPTBW !AirPTBW being the c++ function
REAL*8 a, b, c, d
INTEGER n
d = AirPTBW(a, b, c, n)
I ran dumpbin.exe on the .dll, and the name listed for this specific function is AirPTBW.
There is also a library associtated with the .dll, 'AIRPRP32.lib'. I'm a little confused as to whether I need to include the .lib file somewhere and/or add: !DEC$ DLLIMPORT :: AIRPRP32
I keep getting an error, unresolved external _AirPTBW if I include the .lib file in Confi->Linker->Input->Additional Dependencies. Could it be looking for _AirPTBW, while the .dll outputs it as AirPTBW? If so, how can I fix this?
!DEC$ ATTRIBUTES DLLIMPORT, STDCALL, ALIAS : '_AirPTBW' :: AIRPTBW !AirPTBW being the c++ function
REAL*8 a, b, c, d
INTEGER n
d = AirPTBW(a, b, c, n)
I ran dumpbin.exe on the .dll, and the name listed for this specific function is AirPTBW.
There is also a library associtated with the .dll, 'AIRPRP32.lib'. I'm a little confused as to whether I need to include the .lib file somewhere and/or add: !DEC$ DLLIMPORT :: AIRPRP32
I keep getting an error, unresolved external _AirPTBW if I include the .lib file in Confi->Linker->Input->Additional Dependencies. Could it be looking for _AirPTBW, while the .dll outputs it as AirPTBW? If so, how can I fix this?
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you know for sure that it uses a STDCALL conventiion?
If the problem is really the underscore, just remove it from the ALIAS part of the ATTRIBUTES directive, Keep in mind that saying STDCALL changes the default to pass-by-value. You really need to know the calling interface of the routine in order to be successful - guessing may get you into trouble.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure if it uses STDCALL convention or not. The .dll came bundled with a package that included an .exe, and add-in for excel. The excel add-in has been working fine, and now I want to use the .dll to perform those same functions in my program. The whole thing is older, from '97.
I've added the .lib file to additional dependencies, put the .lib file in a location where it will be found, and changed the compiler directive to:
!DEC$ ATTRIBUTES ALIAS : 'AirPTBW' :: AIRPTBW
Getting error: "unresolved external symbol AirPTBW"
Whole thing looks like this:
program Console1
!DEC$ ATTRIBUTES ALIAS : 'AirPTBW' :: AIRPTBW
implicit real*8 (A-Z)
integer n
a = 14.629D0
b = 83.262D0
c = 72.821D0
d = AirPTBW(a, b, c, n)
end
I've added the .lib file to additional dependencies, put the .lib file in a location where it will be found, and changed the compiler directive to:
!DEC$ ATTRIBUTES ALIAS : 'AirPTBW' :: AIRPTBW
Getting error: "unresolved external symbol AirPTBW"
Whole thing looks like this:
program Console1
!DEC$ ATTRIBUTES ALIAS : 'AirPTBW' :: AIRPTBW
implicit real*8 (A-Z)
integer n
a = 14.629D0
b = 83.262D0
c = 72.821D0
d = AirPTBW(a, b, c, n)
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What does dumpbin -exports on the .lib say?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
COMPILED! Thanks! I didn't know the .lib file would have something different. Now just need to make sure the .dll is working properly. Thanks again.
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