- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to make a Wrapper for a C-build library, however I get the the error message
error LNK2019: unresolved external symbol _asc_initializenetwork@20 referenced in function _MAIN__
What means 20 ?
I have added the library in the Linker->input->Additional Dependencies. So either the name of the function is wrong, or something else. Is there a method to view the declarations of a library subroutine by the dnmnet.lib file. May I have an other problem here ?
INTERFACE
function ASC_initializeNetwork (role,acceptorPort,timeout,network,options)
!DEC$ OBJCOMMENT LIB:'DCMNET.lib'
! Specify C calling and naming conventions
!DEC$ ATTRIBUTES STDCALL :: ASC_initializeNetwork
! input variables
integer role ! T_ASC_NetworkRole
integer acceptorPort
integer timeout
! type(T_ASC_NETWORK)
integer network
integer(4) options
! output variables
integer(2) iErr
END function
end interface
error LNK2019: unresolved external symbol _asc_initializenetwork@20 referenced in function _MAIN__
What means 20 ?
I have added the library in the Linker->input->Additional Dependencies. So either the name of the function is wrong, or something else. Is there a method to view the declarations of a library subroutine by the dnmnet.lib file. May I have an other problem here ?
INTERFACE
function ASC_initializeNetwork (role,acceptorPort,timeout,network,options)
!DEC$ OBJCOMMENT LIB:'DCMNET.lib'
! Specify C calling and naming conventions
!DEC$ ATTRIBUTES STDCALL :: ASC_initializeNetwork
! input variables
integer role ! T_ASC_NetworkRole
integer acceptorPort
integer timeout
! type(T_ASC_NETWORK)
integer network
integer(4) options
! output variables
integer(2) iErr
END function
end interface
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Normally, I would suggest doing a DUMPBIN /symbols DCMNET.LIB on the library to list the symbol names and see what it has for the routine you list. Then it might just require an ALIAS directive added to the Fortran to get the Fortran compiler to generate the correct symbol to match. There may be a problem with the leading underscore, or with the trailing '@20', or the case, or a mixture of all three!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@20 means you have set stdcall compatible checking of stack space used for argument passing. For the last 8 years or so, cdecl is normally used by Visual Studio, but you must choose the same ABI for your C and Fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - anthonyrichards
Then it might just require an ALIAS directive added to the Fortran to get the Fortran compiler to generate the correct symbol to match. There may be a problem with the leading underscore, or with the trailing '@20', or the case, or a mixture of all three!
I recommend against using ALIAS unless you absolutely know that the caller is using STDCALL with undecorated names (VB, etc., will do this.) I have seen people get into trouble by using ALIAS to "fix" a calling convention mismatch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
I recommend against using ALIAS unless you absolutely know that the caller is using STDCALL with undecorated names (VB, etc., will do this.) I have seen people get into trouble by using ALIAS to "fix" a calling convention mismatch.
Currently I do not have the whole source code for the library. I found out, that the library is using the __cdecl convention. However If I use !DEC attributes c :: ASC_initializeNetwork
I still get the error message unresolved external symbol..
However the function ASC_initializeNetwork is defined in the source code I have.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you just say "attributes c", then the name is downcased to asc_initializenetwork (with a leading underscore on IA-32). If the name is as it shows there, then remove the ATTRIBUTES C directive and use this line instead:
function ASC_initializeNetwork (role,acceptorPort,timeout,network,options) BIND(C,NAME='ASC_initializeNetwork)
You will also need to add the VALUE attribute to the arguments that are passed by value (I'm sure some of them are).

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