1

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.

Ivan
  • 673
  • 7
  • 15
  • 1
    you need to declare it as `extern "C"`. i don't know if that's sufficient but it's necessary (from inspection of the mangled name). if you want your library to support Unicode compile as Unicode. – Cheers and hth. - Alf Sep 27 '12 at 13:15

1 Answers1

0

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

Just call it WinMain and you are good to go.

Sebastian Cabot
  • 1,812
  • 14
  • 18
  • Thanks! Now (`extern "C" int APIENTRY WinMain`) compile both "Unicode", and "Multi-byte" mode. – Ivan Oct 09 '12 at 15:58