In the 32bit world it was possible for the linker to create a dll AND a lib file (via the archive command). This was particular useful as it allowed a Qt or VC++ program to call a Fortran function directly using
extern 'C' void FortranFunction(...)
Now however it is necessary to use LoadLibraryA if using VC++, as follows:
#include 'stdafx.h'
#include 'windows.h'
//extern 'C' void VERYSIMPLE(int* input); //old way, with .lib file present
extern 'C' {
typedef void(*VERYSIMPLE_ptr)(int* input);
}
void VERYSIMPLE(int* input)
{
auto hdl = LoadLibraryA('fortran.dll');
if (hdl)
{
auto the_func = reinterpret_cast< VERYSIMPLE_ptr >(GetProcAddress(hdl, 'VERYSIMPLE'));
if (the_func)
the_func(input);
else
printf('no function\n');
FreeLibrary(hdl);
}
else
printf('no library\n');
}
int _tmain(int argc, _TCHAR* argv[])
{
int input1 = 12;
VERYSIMPLE(&input1);
system('pause');
return 0;
}