SDL has a WinMain in its implamentation and declares the SDL_main function. The User can define the body of that function and the entry point in SDL library calls that function.
I want to implement a library with that same implementation. So how do I build a library in c++ that contains the entry point and give to the user a prototype of a function to after be defined and be called like SDL does.
A possible implementation could be:
Lib.hpp:
#define Main lib_main
extern int lib_main ();
Lib.cpp:
#include "lib.hpp"
int main (){
// the lib code runs here
lib_main();
}
after build the this library I can use like so:
main.cpp
#include "lib.hpp"
int Main(){
// The user code
}
I can't compile Lib.cpp with that command:
g++ -shared lib.cpp -o Lib.dll -Wl,--out-implib,libLib.a
it get me a undefined reference for the lib_main().
I'm using windows.