I'm working with a third party C library that is using the default (__cdecl) calling convention and I need to be able to call the third party library from FORTRAN. FORTRAN's default calling convention is __stdcall and so I've written a basic wrapper in C++
int __stdcall wrapper_sub(char* ver, int* days)
{
return original_sub(ver,days);
};
with function prototype
int __stdcall wrapper_sub(char*, int*);
I'm able to compile without errors but when I check the symbol table of the wrapper library I get
?wrapper_sub@@YAHOADPAH@Z(int __cdecl original_sub(char *, int *))
It would seem that the linker is not finding original_sub and the process is failing silently. I've included all necessary references and directories into the project so that the wrapper solution should correctly resolve the third party API.
The FORTRAN call is made as follows
PROGRAM MAIN
IMPLICIT REAL*8 (A-H, O-Z)
CHARACTER*(4) VER
VER = '1.0'
ISTAT = wrapper_sub(VER,IDAYS)
STOP
END
after including an external reference to the wrapper library, I get the following error
error LNK2001: unresolved external symbol _WRAPPER_SUB@12
Is there something I'm missing? or is there a another (less error prone?) way to wrap the C API so that I can call it from FORTRAN?