**** Build of configuration Debug for project testcase ****
make all
Building target: testcase.exe
Invoking: MinGW C+开发者_JAVA技巧+ 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
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)
You're building a Windows Application, but you don't have a WinMain
that is required by Windows applications.
Likely, you have a main
instead. You'll need to either change your project settings (to something along the lines of "Console Application"), or use WinMain
instead. You likely want the former.
Note, WinMain
is not standard. This is just the Windows linkage requirement.
(Is this a duplicate?)
You could keep your main but look up the options
--subsystem,windows -mwindows
in the documentation to your MinGW c++ compiler.
Make sure you got main at least. I fixed mine by providing a main function. I didn't have one when I was compiling. I am on windows.. seems by default it is trying to look for winmain.
I have tried many solutions nothing worked for me.Then I re-created the project and moved the .cpp file to projectname/src/
.
Tested in Eclipse.
If it is executable project then Make sure you should have a entry function main() in your project.
精彩评论