Welcome! Log In Create A New Profile

Advanced

undefined reference to `WinMain@16'

Posted by Anonymous User 
Position: School of Computing Forums > 2006 > COS3114
AnnouncementsLast Post
AnnouncementRegistration as a user on these forums09/01/2014 11:31AM
AnnouncementmyUnisa access problems02/04/2014 10:25AM
Announcement3G Internet access offer for students03/13/2014 06:51PM
AnnouncementForms you may need06/04/2013 10:20AM
AnnouncementUnisa contact information07/28/2011 01:28PM
Anonymous User
undefined reference to `WinMain@16'
July 02, 2006 01:32PM
Hi
I am receing the folloing from the compiler:

C:\unisa\mico\demo\poa\A3last>gmake
g++ -mthreads -Lc:/unisa/mico/libs -o client.exe c:/unisa/mico/bin/mico2311.dll
-lmicocoss2.3.11 -lpthread
c:/unisa/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/../../../libmingw32.a(main.o)(.t
ext+0x97):main.c: undefined reference to `WinMain@16'
gmake: *** [client.exe] Error 1

Is this problem in my code or somewhere else?

Thanks
Re: undefined reference to `WinMain@16'
July 03, 2006 01:58PM
Tell your compiler to create a console application, not a windows application.
Anonymous User
Re: undefined reference to `WinMain@16'
July 05, 2006 07:13PM
Thanks Sirius,but how should I do this.This not a project that I can create as a console application.It is a collection of sepperate files.
help will be appreciated.
Anonymous User
Re: undefined reference to `WinMain@16'
July 06, 2006 11:10AM
Does anyone have an idea what I should should do.If I do not solve this problem quickly I will not be allowed for exams.
Thanks for any help.
Re: undefined reference to `WinMain@16'
July 06, 2006 11:54AM
Paste the contents of your makefile so we can see what it looks like
Anonymous User
Re: undefined reference to `WinMain@16'
July 06, 2006 01:03PM
My account and bank classes is in a single file


include c:/unisa/mico/MakeVars

# IDLFLAGS = --c++-impl
SERVEROBJS = Account.o Account_impl.o server.o
CLIENTOBJS = Account.o client.o

all: server.exe client.exe

server.exe: $(SERVEROBJS)
$(LD) $(LDFLAGS) -o server.exe $(SERVEROBJS) $(LDLIBS)

client.exe: $(CLIENTOBJS)
$(LD) $(LDFLAGS) -o client.exe $(CLIENTPBJS) $(LDLIBS)

client.o: Account.h
server.o: Account.h Account_impl.h
Account.o: Account.cc Account.h
Account_impl.o: Account_impl.cc Account_impl.h Account.h

account.h account.cc: account.idl
$(IDL) $(IDLFLAGS) $<

clean:
rm -Rf $(SERVEROBJS) $(CLIENTOBJS) Account.h Account.cc *.exe *~
Re: undefined reference to `WinMain@16'
July 06, 2006 03:52PM
This actually looks fine, except for the hidden data in Makevars. Can you post that too? The problem you're getting is the linker is trying to find definitions for WinMain, and the options being passed to the linker are defined in the Makevars file.
Anonymous User
Re: undefined reference to `WinMain@16'
July 06, 2006 05:36PM
All of this was on a single line when I opened the file in nodepad.I have not changed or removed anything from this file.



MICO = c:/unisa/mico

CXX = g++
CXXFLAGS = -mthreads -I$(MICO)/include -D_REENTRANT
LD =
$(CXX)
LDFLAGS = -mthreads
-L$(MICO)/libs
LDLIBS = $(MICO)/bin/mico2311.dll -lmicocoss2.3.11
-lpthread
IDL = $(MICO)/bin/idl.exe
MKDEPEND = $(MICO)/bin/mkdepend.exe

.depend:



Thanks for the help.I appreciate it.
Re: undefined reference to `WinMain@16'
July 07, 2006 08:29AM
Okay, that also looks fine. I'm not sure about the MKDEPEND option. I'll have to check my own makefile, which I don't have with me at work. I'll look into it at home and see if there's anything obvious. I'm pretty sure the problem is that the compiler is, for some reason or other, trying to make a windows application instead of a console application.

Just out of interest, have you tried compiling your code in whatever IDE you use (Dev-C++)?
Re: undefined reference to `WinMain@16'
July 07, 2006 08:32AM
Actually, wait, I'm being stupid. The canonical answer to this question, from the Bloodshed web site, is:

"You probably haven't declared any main() or WinMain() function in your program."

So I looked at your makefile again. You're not telling it to compile server.cc
Anonymous User
Re: undefined reference to `WinMain@16'
July 07, 2006 10:53AM
Hi,my makefile looks as follow:
I havent compiled the code in my IDE.Should I compile it as a single project or should I compile each file seperatly ?

My makefile now look like this.

include c:/unisa/mico/MakeVars

# IDLFLAGS = --c++-impl
SERVEROBJS = Account.o Account_impl.o server.o
CLIENTOBJS = Account.o client.o

all: server.exe client.exe

server.exe: $(SERVEROBJS)
$(LD) $(LDFLAGS) -o server.exe $(SERVEROBJS) $(LDLIBS)

client.exe: $(CLIENTOBJS)
$(LD) $(LDFLAGS) -o client.exe $(CLIENTPBJS) $(LDLIBS)

client.o: client.cc Account.h
server.o: server.cc Account.h Account_impl.h
Account.o: Account.cc Account.h
Account_impl.o: Account_impl.cc Account_impl.h Account.h

Account.h Account.cc: Account.idl
$(IDL) $(IDLFLAGS) $<

clean:
rm -Rf $(SERVEROBJS) $(CLIENTOBJS) Account.h Account.cc *.exe *~



The compiler still gives me this output


C:\unisa\mico\demo\poa\A3last>gmake
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o Account.o Account.cc
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o Account_impl.o Accoun
t_impl.cc
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o server.o server.cc
g++ -mthreads -Lc:/unisa/mico/libs -o server.exe Account.o Account_impl.o server
.o c:/unisa/mico/bin/mico2311.dll -lmicocoss2.3.11 -lpthread
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o client.o client.cc
g++ -mthreads -Lc:/unisa/mico/libs -o client.exe c:/unisa/mico/bin/mico2311.dll
-lmicocoss2.3.11 -lpthread
c:/unisa/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/../../../libmingw32.a(main.o)(.t
ext+0x97):main.c: undefined reference to `WinMain@16'
gmake: *** [client.exe] Error 1

C:\unisa\mico\demo\poa\A3last>


Maybe I should redo everything,but what if I just run into the same problem again.

Thanks.It really means a lot that someone is trying to help.
Re: undefined reference to `WinMain@16'
July 07, 2006 12:24PM
Mail me your client.cc file and let me take a look at it.
Re: undefined reference to `WinMain@16'
July 07, 2006 04:03PM
Don't know if this will cause it, but in your make file you made a typo.

client.exe: $(CLIENTOBJS)
$(LD) $(LDFLAGS) -o client.exe $(CLIENTPBJS) $(LDLIBS)

Check the CLIENTOBJS.
Anonymous User
Re: undefined reference to `WinMain@16'
July 07, 2006 05:29PM
Thanks a lot trautw.You have solved this mistery.I should have my eyes tested.
Sorry, only registered users may post in this forum.

Click here to login