Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
640 views
in Technique[技术] by (71.8m points)

undefined reference to WinMain Error 1 in eclipse using mingw

**** Build of configuration Debug for project testcase ****

make all 
Building target: testcase.exe
Invoking: MinGW C++ Linker
g++  -o"testcase.exe"  ./atest.o ./main.o  C:/cppunit/src/cppunit/.libs/libcppunit.a 
/mingw/lib/libmingw32.a(main.o):main.c:(.text+0xd2): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
make: *** [testcase.exe] Error 1

undefined reference to `WinMain@16' : mingw/lib/libmingw32.a(main.o):main.c:    
make: *** [testcase.exe] Error 1 

but am using an cpp program. in cpp program which has main.cpp, atestcase.cpp and a.hpp but it showing main.c:(.text+0xd2):

Can any one solve this problem .please can any one help me yours faithfully, r.kranthikumar

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First, check you did actually save your main.c file (eclipse does not automatically save a source file)

Then, check if your makefile is autogenerated or if you can write it yourself, as in this thread.

CXXFLAGS = -O2 -g -Wall -fmessage-length=0

OBJS =  main.o

LIBS =

TARGET =    say.exe

$(TARGET):  $(OBJS)
    $(CXX) -o $(TARGET) $(OBJS) $(LIBS)

all:    $(TARGET)

clean:
    rm -f $(OBJS) $(TARGET)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...