- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a DLL I can call from a C program, but not from fortran. When I build the fortran program, I get unresolved external.
The c prototype for the function is hasp_status_t HASP_CALLCONV hasp_logout(hasp_handle_t *handle);
hasp_handle_t appears to be unsigned long in C
hasp_status_t appears to be an integer. It's actually an enum so I think that means it's a regular integer.
HASP_CALLCONV appears to be __stdcall
How do call this from fortran? I've tried types integer for the return value and c_int32_t for the handle argument, but the linker gives me unresolved external. I have both the DLL and its corresponding .LIB file which I have included in the visual studio project.
use, intrinsic :: iso_c_binding implicit none interface function hasp_logout(handle) result(retval) bind(C, name="hasp_logout") import integer(c_int32_t) :: handle integer :: retval end function end interface
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It would help us help you if you showed us 1) the linker error message, 2) the part of a "dumpbin -exports" for the DLL showing the name of the routine.
You can add:
!DEC$ ATTRIBUTES STDCALL to the interface to make it STDCALL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When one investigates problems with STDCALL, it is usually helpful to know if we are talking about 32-bit or 64-bit code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the replies. It is 32 bit code, and the linker error message is.....
CheckSentinelKey.obj : error LNK2019: unresolved external symbol _hasp_logout referenced in function _CHECKSENTINELKEY Debug\SentinelFortran.exe : fatal error LNK1120: 1 unresolved externals
Compile and Link command lines are.....
/nologo /debug:full /Od /warn:interfaces /module:"Debug\\" /object:"Debug\\" /Fd"Debug\vc100.pdb" /traceback /check:bounds /check:stack /libs:static /threads /dbglibs /c /OUT:"Debug\SentinelFortran.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"C:\Users\Brian\Documents\Visual Studio 2010\Projects\SentinelFortran\SentinelFortran\Debug\SentinelFortran.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Brian\Documents\Visual Studio 2010\Projects\SentinelFortran\SentinelFortran\Debug\SentinelFortran.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"C:\Users\Brian\Documents\Visual Studio 2010\Projects\SentinelFortran\SentinelFortran\Debug\SentinelFortran.lib"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dependency walker shows the routine name as hasp_logout all lower case. When I look inside the .LIB file for the DLL I see _hasp_logout@4
dumpbin showed the following:
47 16 002C9E06 HL_LOGOUT 14 41 0019056F hasp_logout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried the !DEC$ statement again.
function hasp_logout(handle) result(retval) bind(C, name="hasp_logout") !DEC$ ATTRIBUTES STDCALL :: hasp_logout import integer(c_int32_t) :: handle integer :: retval end function
and this generated a compile error
...\CheckSentinelKey.f90(14): error #8143: The BIND(C) attribute for this symbol conflicts with a DEC$ ATTRIBUTES ALIAS, DECORATE, STDCALL, C, [NO_]MIXED_STR_LEN_ARG or REFERENCE attribute for this symbol. [HASP_LOGOUT]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What compiler version is that, is it an old one? The code below compiles OK with no errors. I am recalling a bug in an older version with use of RESULT, BIND Name= and STDCALL if my memory is good. Try it without using result.
module test use, intrinsic :: iso_c_binding implicit none interface function hasp_logout(handle) result(retval) bind(C, name="hasp_logout") !DEC$ ATTRIBUTES STDCALL :: hasp_logout import integer(c_int32_t) :: handle integer :: retval end function end interface end module test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>integer(c_int32_t) :: handle
While your program is currently 32-bit, in the future you or your successor may port to 64-bit. Therefore, consider future-proofing your program by using
integer(int_ptr_kind()) :: handle
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My compiler version is Intel(R) Visual Fortran Composer XE 2013 Update 5 Integration for Microsoft Visual Studio* 2010, 13.0.3636.2010,
The following still generates compile error 8143
module sentinel_api_mod use, intrinsic :: iso_c_binding implicit none interface function hasp_logout(handle) bind(C, name="hasp_logout") !DEC$ ATTRIBUTES STDCALL :: hasp_logout import integer(c_int32_t) :: handle integer :: hasp_logout end function END interface end module sentinel_api_mod
If remove the !DEC$ statement, compiling succeeds but linking fails with errors in post #4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The bind(C... clause and the DEC$ directives are in conflict. Try removing the bind(C... part from the fifth line of the code in #9 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In that old version, you could not use BIND(C) and STDCALL together. That changed in a later version. If you must use that version, you can't use BIND(C) if you need STDCALL and will have to use directives for everything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Intel Software Manager tells me "you currently have the latest", but of course I don't. When I try to login at signin.intel.com it won't let me login with credentials I know were good in 2017 and 2018. I was able to login with older credentials from 2013, but that doesn't get me access to my current license.
In my Downloads folder I see I have downloaded the following files:
parallel_studio_xe_2018_update2_composer_edition_setup.exe
parallel_studio_xe_2017_update2_composer_edition_setup.exe
Can I install either of these without breaking anything? Composer XE 2013 was bought and installed on one Serial number, and I have been using it with visual studio 2010 ever since. In 2017 a new license for Intel Fortran,C++ and IMSL was purchased with a new serial number. I never installed it out of fear of breaking my current setup because I read somewhere it was not compatible with visual studio 2010.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brian Murphy wrote:The Intel Software Manager tells me "you currently have the latest", but of course I don't. When I try to login at signin.intel.com it won't let me login with credentials I know were good in 2017 and 2018. I was able to login with older credentials from 2013, but that doesn't get me access to my current license.
In my Downloads folder I see I have downloaded the following files:
parallel_studio_xe_2018_update2_composer_edition_setup.exe
parallel_studio_xe_2017_update2_composer_edition_setup.exe
Can I install either of these without breaking anything? Composer XE 2013 was bought and installed on one Serial number, and I have been using it with visual studio 2010 ever since. In 2017 a new license for Intel Fortran,C++ and IMSL was purchased with a new serial number. I never installed it out of fear of breaking my current setup because I read somewhere it was not compatible with visual studio 2010.
Brian:
You need help from inside Intel. Devorah is the person who usually solves this type of problem for me in terms of access. I strongly suggest you send her a private message - click on the icon next to your name on top right and you can see the private.
She is excellent at sorting these types of access problems.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, my intel product registration is hopelessly messed up. I need to talk to someone over the phone to fix it. Do you know of a phone number?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I found the private message area by clicking near my name in the upper right, but could not figure out how to submit a message. The name Devorah rings a distant bell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You won't be able to start a private message thread - only Intel people and Black Belts can do that. There is no phone number available.
All licensing issues are supposed to be reported through the Online Service Center.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I sent a distress call to inteldeveloperzonesupport@intel.com. Hopefully they can clean up the mess with my registrations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That may take a while to route properly - that team does not deal with product or licensing issues, they're strictly for issues with the IDZ web site. They may try to find the right team to handle it, but it depends a lot on who sees the message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I managed to submit the same thing at the intel Online Service Center. I'll keep my fingers crossed.
Can you tell me if
parallel_studio_xe_2018_update2_composer_edition_setup.exe
is compatible with visual studio 2010?
Meanwhile, I took out the BIND(C stuff and the program now compiles and links. Yippee! So on to my next hurdle which is hasp_login that requires passing a string argument. Yuck! I will start another thread for that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brian Murphy wrote:
Can you tell me ifparallel_studio_xe_2018_update2_composer_edition_setup.exe
is compatible with visual studio 2010?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also https://software.intel.com/en-us/intel-parallel-studio-xe-compilers-required-microsoft-visual-studio - answer is "No".

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page