Entry point from dll? (framework)

I'm trying to make a framework
and so would like to have the entry point be in the dll of the framework.

I have a 'win32_platform.cpp' file which is what gets compiled down to the dll

and then i have a 'spike.cpp' file which is what links to the dll and gets compiled down to the executable

the win32_platform.cpp just contains the WinMain function.
and the spike.cpp file literally contains nothing right now.

When i build the dll (so, win32_platform.cpp) i get no errors

but then when i build the executable i get: undefined reference to `WinMain@16'

so it seems that the linker cant figure out that the entry point is in the dll.
is there a way to tell it?

(im using mingw btw)
Last edited on
Both DLLs and EXEs are executables, and all executables must have entry points. There's just no way around this, since something must happen when the executable gets loaded.
oh
but isn't the definition of a framework that it will be the entry point and later call in to your program ?

but if the executable has to have an entry point then
how is that achieved then?



but isn't the definition of a framework that it will be the entry point and later call in to your program ?
Erm... No, not even close.
https://en.wikipedia.org/wiki/Software_framework

I think I understand what you mean.
You want the control flow to work like this:
1. Program starts
2. Control passed to win32_platform.dll
3. win32_platform.dll does some initialization.
4. win32_platform.dll calls a special function in spike.exe
5. spike.exe executes from then on.
Is that right? I would advice against doing that, if possible. Libraries that do this are annoying to use.

But if you still want to do it, here's how it can be done.
First you create a static library that will implement WinMain() for the user's EXE. This WinMain() will simply call into the DLL's entry point. The static library will be part of your framework.
Then the user's EXE should link to the static library. This will let it have an entry point without having to explicitly define one.
That should do it. Now both the DLL and the EXE have entry points, but the EXE looks like it doesn't.
Topic archived. No new replies allowed.