使用 mingw 在 Eclipse 中对 WinMain 错误 1 ​​的未定义引用

kra*_*mar 2 eclipse

**** 为项目测试用例构建配置调试 ****

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 
Run Code Online (Sandbox Code Playgroud)

但我正在使用 cpp 程序。在具有 main.cpp、atestcase.cpp 和 a.hpp 但它显示 main.c:(.text+0xd2) 的 cpp 程序中:

任何人都可以解决这个问题。请任何人忠实地帮助我,r.kranthikumar

Von*_*onC 5

首先,检查您是否确实保存main.c文件(eclipse 不会自动保存源文件)

然后,检查您的 makefile 是否是自动生成的,或者您是否可以自己编写,就像在这个线程中一样

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)
Run Code Online (Sandbox Code Playgroud)