Linker cannot find WinMain() in object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Min Sheng Lu (minsheng.lu_at_antlimited.com)
Date: 07/09/04


Date: Fri, 09 Jul 2004 18:21:51 +0100

Hi all,

I am porting an application to WinCE.net, and I found that compilation
fails at the linking stage as the linker cannot find the entry point in
my compiled objects:

"LIBC.lib(wincrt0.obj) : error LNK2019: unresolved external symbol
_WinMain@16 referenced in function _WinMainCRTStartup"

Now this is strange as WinMain() is declared correctly and compiled ok,
and the linker options have /entry:WinMainCRTStartup set so things
should work ok.

I am currently linking against winmgr.lib, coredll.lib and winsock.lib
only, and NOT corelibc.lib, would that make a difference?

I tried to write a dummy test function, shown below, and tried to link
that against coredll.lib but the linker still gives the same error. So a
bit confused now and any help would be much appreciated.

Thanks

Min

file:main.c

#include <winbase.h>

int
WINAPI
WinMain(
     HINSTANCE hInstance,
     HINSTANCE hPrevInstance,
     LPWSTR lpCmdLine,
     int nShowCmd
     )
{
     int argc = __argc;
     char **argv = __argv;
     NOT_USED( hPrevInstance);
     NOT_USED( lpCmdLine);

     /* skip function name */
     argc--;
     argv++;
     return 0;
}

Linker output:

C:/WINCE420/SDK/BIN/I386/link /nologo /base:"0x00010000"
/stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /incremental:no
/pdb:"SIS550" /out:bin/main.exe main.obj coredll.lib
LIBC.lib(wincrt0.obj) : error LNK2019: unresolved external symbol
_WinMain@16 referenced in function _WinMainCRTStartup
main.exe : fatal error LNK1120: 1 unresolved externals



Relevant Pages

  • Re: g21k on GNU/Linux system [status update]
    ... expected conflicts is 10 instead of 8. ... this point the compilation went through with minor warnings on ... I will still need to build the assembler and the linker and eventually I ... but now I'm missing ldr21k and spl21k to generate the hex file format to ...
    (comp.dsp)
  • Variadic functions calling variadic functions with the argument list, HLL bit shifts on LE processor
    ... also I have some questions about shift on little-endian ... but one would hope that the shr for shift right instruction would ... but it's about the linker. ... All of those definitions are in the same compilation or translation ...
    (comp.lang.c)
  • Re: namespaces and main()
    ... having multiple definitions is ... Actually it's quite a big problem for the linker to sort out - some ... translation unit and not compile it in any of the others. ... One way around the bloat issue is just to have a single compilation ...
    (comp.lang.cpp)
  • Linker cannot find WinMain() in object
    ... I am porting an application to WinCE.net, and I found that compilation ... fails at the linking stage as the linker cannot find the entry point in ... and the linker options have /entry:WinMainCRTStartup set so things ... HINSTANCE hInstance, ...
    (microsoft.public.windowsce.embedded)
  • Re: Linker cannot find WinMain() in object
    ... > _WinMain@16 referenced in function _WinMainCRTStartup" ... > and the linker options have /entry:WinMainCRTStartup set so things ... HINSTANCE hInstance, ... int nShowCmd ...
    (microsoft.public.windowsce.app.development)