On Mon, Sep 10, 2007 at 11:09:21PM +0100, Matthew Kille wrote:
> Hi All,
> 
> (Using mingw32ce toolchain, revision 1049 I believe.)
> 
> Can someone help explain to me the mechanisms behind how the 'dummy 
> WinMain' function (in winmain_ce.c) is conditionally linked into the 
> output binary if the developer doesn't provide his own WinMain() function?

A ".a" file is composed of a set of ".o" files.  When linking with a
".a" library, the linker will only pull in those ".o" files that
resolve an outstanding symbol.  So, if the linker doesn't have WinMain
outstanding, it shouldn't try to pull in winmain_ce.o.

> My problem is that I *am* providing my own WinMain() function but it is 
> tucked away inside a static link library rather than in the source files 
> I am compiling. When building, the linker says that there is a multiple 
> definition of WinMain. See error below:
> 
> $ arm-wince-mingw32ce-gcc -o output.exe main.c -lmylib
> [...]/arm-wince-mingw32ce/lib/libmingw32.a(winmain_ce.o): In function 
> `WinMain':
> [...]/cegcc/src/mingw/winmain_ce.c:143: multiple definition of `WinMain'
> [...]/libmylib.a(main.o):main.c:(.text+0x0): first defined here
> [...]/arm-wince-mingw32ce/lib/libmingw32.a(winmain_ce.o):winmain_ce.c:(.text+0x1e0):
>  
> undefined reference to `main'
> collect2: ld returned 1 exit status

Odd.  Out of curiousity, does the following work:

$ arm-wince-mingw32ce-gcc -o output.exe main.c libmylib.a

if not, how about:

$ arm-wince-mingw32ce-gcc -o output.exe libmylib.a main.c

-Kevin

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to