Re: Linker cannot find WinMain() in object

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

From: Michael J. Salamone [eMVP] (mikesa#at#entrek#dot#com)
Date: 07/11/04


Date: Sun, 11 Jul 2004 16:15:27 -0700

Link against corelibc. libc.lib is not used in Windows CE, and is not
anything you should have in your SDK or on your lib path.

-- 
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
"Min Sheng Lu" <minsheng.lu@antlimited.com> wrote in message
news:evjW6kdZEHA.1152@TK2MSFTNGP09.phx.gbl...
> 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: 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.embedded)
  • Re: How a linker works (continued)
    ... implement software that handles a particular object format. ... The linker opens all object files that it receives, ... not in the common section. ... is seen by the end of the translation unit, it is treated as ``int ...
    (comp.lang.c)
  • Re: Newbie Linking Error
    ... The error is indeed during the linking, the linker tries to find your ... > before the `int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, ... do with C++ it teaches you how to use some OS libraries (namely Win32 ...
    (comp.lang.cpp)
  • Re: TLS, Thread Local Storage..
    ... linker etc that are going to be the problems.. ... extern __thread int e; ... The BIG question is "who knows enough about the dynamic linker to be ...
    (freebsd-current)
  • Re: C++ Project Files?????
    ... write "int Hello", I always write "int Hello", I also always include ... Mr Linker won't even hear about these functions! ... So just how much of all this is in the C++ Standard? ... So I think to myself: "Is my program starting at "WinMain", or is it starting at "main", and is "main" just hidden away in some object/library file and looks like this: int main{//blah blah blah ...
    (comp.lang.cpp)