- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been attempting to access a c function that is located in a .dll file. The function is called PSLM_GetKey, and it returns an integer type. My interface for the c function is below:
INTERFACE
FUNCTION PSLM_GetKey
!DEC$ ATTRIBUTES C :: PSLM_GetKey
!DEC$ ATTRIBUTES DLLImport :: PSLM_GetKey
END FUNCTION PSLM_GetKey
END INTERFACE
Within my fortran code, I attempt to call the fuction using:
ikey = PSLM_GetKey()
When compiling, I receive the following error:
unresolved external symbol _pslm_getkey
Is there anything obvious that I am doing incorrectly? Is it necessary to have the dll's .lib file added to my project? What if I only have access to the .dll file itself?
Thanks, Barry
INTERFACE
FUNCTION PSLM_GetKey
!DEC$ ATTRIBUTES C :: PSLM_GetKey
!DEC$ ATTRIBUTES DLLImport :: PSLM_GetKey
END FUNCTION PSLM_GetKey
END INTERFACE
Within my fortran code, I attempt to call the fuction using:
ikey = PSLM_GetKey()
When compiling, I receive the following error:
unresolved external symbol _pslm_getkey
Is there anything obvious that I am doing incorrectly? Is it necessary to have the dll's .lib file added to my project? What if I only have access to the .dll file itself?
Thanks, Barry
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it is necessary to have dll's .lib file inserted to your project. Moreover, you should take care of name mangling, which is different in CVF, C and C++. If adding .lib to your project still doesn't work (linker error), you should examine real mangled name of C function using:
dumpbin /exports xxx.dll
and add an ALIAS directive to INTERFACE block (such as !DEC$ATTRIBUTES ALIAS: '_PSLM_GetKey':: PSLM_GetKey -- case is important). Note that if the C dll was compiled with VC++ and
Jugoslav
dumpbin /exports xxx.dll
and add an ALIAS directive to INTERFACE block (such as !DEC$ATTRIBUTES ALIAS: '_PSLM_GetKey':: PSLM_GetKey -- case is important). Note that if the C dll was compiled with VC++ and
extern "C"
directive was ommited from .cpp file, you could get as ugly a mangled name as ?_PSLM_GetKey@YAXXHUZ
. Jugoslav

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