N
Nik-Lz
Guest
I have the following Windows dll with a DllMain function:
#include <cstdio>
#include <Windows.h>
extern "C" bool __stdcall DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved)
{
switch(ulReasonForCall) {
case DLL_PROCESS_ATTACH:
puts("Dll called for DLL_PROCESS_ATTACH");
break;
case DLL_PROCESS_DETACH:
puts("Dll called for DLL_PROCESS_DETACH");
break;
default:
break;
}
return true;
}
Then I compile and link:
cl /c dll_with_entry.cpp
link dll_with_entry.obj /DLL /ENTRYllMain
Compilation goes well, linking with `link.exe` displays the following output:
dll_with_entry.obj : error LNK2019: unresolved external symbol puts referenced in function DllMain
dll_with_entry.dll : fatal error LNK1120: 1 unresolved externals
Clearly linker doesn't recognize the symbol DllMain. However this very same program works inside the Visual Studio 2017 IDE, without any alterations whatsoever. So what is wrong here? I believe I'm doing everything correctly, but apparently I'm not. Thanks in advance.
Continue reading...
#include <cstdio>
#include <Windows.h>
extern "C" bool __stdcall DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved)
{
switch(ulReasonForCall) {
case DLL_PROCESS_ATTACH:
puts("Dll called for DLL_PROCESS_ATTACH");
break;
case DLL_PROCESS_DETACH:
puts("Dll called for DLL_PROCESS_DETACH");
break;
default:
break;
}
return true;
}
Then I compile and link:
cl /c dll_with_entry.cpp
link dll_with_entry.obj /DLL /ENTRYllMain
Compilation goes well, linking with `link.exe` displays the following output:
dll_with_entry.obj : error LNK2019: unresolved external symbol puts referenced in function DllMain
dll_with_entry.dll : fatal error LNK1120: 1 unresolved externals
Clearly linker doesn't recognize the symbol DllMain. However this very same program works inside the Visual Studio 2017 IDE, without any alterations whatsoever. So what is wrong here? I believe I'm doing everything correctly, but apparently I'm not. Thanks in advance.
Continue reading...