Question

I try put main(WinMain) in static library:

#include <tchar.h>
#include <Windows.h>

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow) {...}

but I got:

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

I tried to build as "Unicode", and as "Multi-byte".

I tried write without "_t" (and LPSTR).

I tried write extern "C".

Linker flags include /SUBSYSTEM:WINDOWS and my static lib

I know that it's possible, because it's done in libraries like SDL, SFML, etc.

Was it helpful?

Solution

Your problem is that the function in the lib is called _tWinMain.

Just call it WinMain and you are good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top