When I try to create a DLL and export a function from it:
__declspec(dllexport) CeRenderDevice *CreateDevice(void);
[/source]
And then load the DLL in my main program with:
[source]
HMODULE hLib = LoadLibrary( szLib );
FARPROC pfCreate = GetProcAddress( hLib, "CreateDevice" );
I get errors. The LoadLibrary succeeds, giving me a handle, but GetProcAddress fails with an error "The specified procedure could not be found".
So, I check the .dll file with
dumpbin /exports cedevice.dll
and get this list:
File Type: DLL
Section contains the following exports for cedevice.dll
0 characteristics
39950361 time date stamp Sat Aug 12 09:57:21 2000
0.00 version
1 ordinal base
4 number of functions
4 number of names
ordinal hint RVA name
1 0 00001014 ?CreateDevice@@YAPAVCeRenderDevice@@XZ
2 1 00033C40 ?nCeRenderDeviceMajorVersion@@3HA
3 2 000359A8 ?nCeRenderDeviceMinorVersion@@3HA
4 3 00033C44 ?szCeRenderDeviceName@@3PADA
Summary
5000 .data
1000 .idata
3000 .rdata
2000 .reloc
2F000 .text
Wtf! How do I tell VC++ to not mangle my exports to "?CreateDevice@@YAPAVCeRenderDevice@@XZ" and such things?