The only way to access a bare DLL without a .lib file is to load the DLL explicitly using LoadLibrary() , get the pointers to the exported functions that you want to access with GetProcAddress() , and then put these pointers on the corresponding function signature. If the library exports C ++ functions, the names you must pass to GetProcAddress() will be garbled. You can specify the exported dumpbin /exports your.dll .
extern "C" { typedef int (*the_func_ptr)( int param1, float param2 ); } int main() { auto hdl = LoadLibraryA( "SomeLibrary.dll" ); if (hdl) { auto the_func = reinterpret_cast< the_func_ptr >( GetProcAddress( hdl, "the_func" ) ); if (the_func) printf( "%d\n", the_func( 17, 43.7f ) ); else printf( "no function\n" ); FreeLibrary( hdl ); } else printf( "no library\n" ); return 0; }
As others have noted, a LIB file can be created. Get the list of exported functions from dumpbin /exports your.dll :
ordinal hint RVA name 1 0 00001000 adler32 2 1 00001350 adler32_combine 3 2 00001510 compress (etc.)
Put the names in the DEF file:
EXPORTS adler32 adler32_combine compress (etc.)
Now create the LIB file:
lib /def:your.def /OUT:your.lib
In cases where the name was decorated, either using the C ++ language name, or using the stdcall 32-bit calling stdcall , just copy and paste any dumpbin names that will be displayed, swing and that's it.
Khouri giordano
source share