Reputation: 215
**** 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
Upvotes: 2
Views: 24574
Reputation: 1
If it is executable project then Make sure you should have a entry function main() in your project.
Upvotes: 0
Reputation: 1457
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.
Upvotes: 0
Reputation: 11
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.
Upvotes: 1
Reputation:
(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.
Upvotes: 2
Reputation: 503765
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.
Upvotes: 2
Reputation: 1323115
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)
Upvotes: 5