undefined reference to 'WinMain@16'

Started by
4 comments, last by stefu 21 years, 10 months ago
I need to compile my project from Linux to Windows. It''s not hard task, because I''v used SDL and OpenGL. Everything compiles well, but can''t find out what''s problem withlinking! Undefined reference to ''WinMain@16'' must be very common error :doubt: I have int main(int argc, char *argv[]) in one of my source cpp''s. Could anyone tell from experience the problem is where? I''v already fought with this proble three hours, gotta rest now a little Here something I think might help:
  
#makefile
CC=g++

INCLUDE=-I/usr/include -I/usr/include/freetype2 -L../gamelibrary -L/gcc-2.95.2/i386-mingw32msvc/lib

LIBS= -lgamelibrary -lopengl32 -lglu32 -lSDL -lfreetype 

%.o : %.cpp
	$(CC) $(INCLUDE) -c -o $@ $<

test: test.o terrain.o
	$(CC) $^ -o test.exe $(LIBS) $(INCLUDE) -s

clean :
	rm *.o

all : clean test
  

  
C:\Omat tiedostot\Stefan\prog\test_1>make
g++ test.o terrain.o -o test.exe -lgamelibrary -lopengl32 -lglu32 -lSDL -lfreetype  -I/usr/include -I/usr/include/freetype2 -L../gamelibrary -L/gcc-2.95.2/i386-mingw32msvc/lib -s /gcc-2.95.2/i386-mingw32msvc/lib\libmingw32.a(main.o)(.text+0x8e): undefined reference to `WinMain@16''
MAKE.EXE: *** [test] Error 1
  
I installed gcc package I found link in cone3d.gamedev.net. Thanks for any help
Advertisement
If I remember well, you also have to link the SDLmain library.
Thank you sooo much!!!

Btw. why does the order of libraries matter?

If order is -lopengl32 -lglu32 -lgamelibrary then I get a lot of undefined reference to gl* functions in my gamelibrary.

But if I flip order -lgamelibrary -lopengl32 -lglu32 then it's ok.

Also -lSDLmain has to be before -SDL.

I wonder why, I remember never having such case before.

[edited by - stefu on June 6, 2002 12:37:54 PM]
quote:Original post by stefu
Btw. why does the order of libraries matter?


I don''t know, I''ve never had any order problems for linking (note I mainly use MSVC), maybe some gcc guru could enlight us ?
Order matters, in linking, compiling, and code.
Ok.



[edited by - stefu on June 9, 2002 6:24:33 AM]

This topic is closed to new replies.

Advertisement