I'm writing a cross-platform library that is supposed to work on Windows, Linux, *BSD and Mac OS X.
Because Windows GUI applications require WinMain/wWinMain as the entry point, I've created a separate static lib file (a-la SDL_main.lib) that looks like this:
#include <windows.h>
extern int main(int argc, char *argv[]);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
. . .
// lpCmdLine is parsed to argc and argv
. .
main(argc, argv);
. . .
return 0;
}
Then an application that wants to link with my library needs to link with main.lib (on Windows only) but the main.c is the same on all platforms:
int main(int argc, char *argv[])
{
. . .
return 0;
}
This works as intended, and does not even require re#defining main() as SDL_main.{c,h} does,
nor it requires AL_END_OF_MAIN after main() as Allegro does.
But if I change WinMain to wWinMain:
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
- the linker fails:
POLINK: error: Unresolved external symbol '_WinMain@16'.
POLINK: fatal error: 1 unresolved external(s).
Any ideas why it looks for WinMain?
If this matters - I have UNICODE and _UNICODE defined.