I Googled out this error and it seems that the main I'm using is for a Window application but there's no clear answer, they just go, "Oh you know, it's because you're using a console application".
Now, do I just replace this line BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
by this int main()?
Also, I want to insist that whatever alternative causes the least security gap, this is why I'm posting the question here...
I want to create a DLL, what options do I have to set (I'm using Code::Blocks, but you can point directions for MSVC as well). In other words, how do I write the entry point of the code to be compiled as a DLL?
If you're building a DLL, the linker should not be looking for a program entry point. It sounds like your project is set up to build an app rather than a lib.
A DLL's entry point is DLLMain(), I mean it gets called by the loader.
But a main or WinMain will never be called in a DLL, nothing expects them to be there and they shouldn't be there. If the linker is complaining that one these is missing, the linker is misconfigured and is trying to link a program.
#include "main.h"
// ... more function definitions
// function1() definition
// !! function1() used to be main(), but I changed a lot of things so that it
// becomes a function on its own
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}