2010-01-11 29 views
1

****配置調試的建立項目測試用例****未定義參照的WinMain錯誤1中的mingw蝕

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 `[email protected]' 
collect2: ld returned 1 exit status 
make: *** [testcase.exe] Error 1 

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

但正在使用的CPP程序。在cpp程序中有main.cpp,atestcase.cpp和a.hpp,但是它顯示的是main.c :(。text + 0xd2):

任何人都可以解決這個問題。請問能否幫助我 , r.kranthikumar

回答

4

首先,檢查你did actually save your main.c file(日食不會自動保存源文件)

然後,或檢查你的makefile是自動生成的,如果你可以把它寫自己,在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) 
+0

另請參閱http://yongshin.blogspot.com/2005/11/how-to-use-cdt-and-mingw-for-eclipse.html#c8263974258284865 – VonC 2010-01-11 09:46:10

2

你正在建設一個Windows應用程序,但你不必由Windows應用所需的WinMain

可能,您有一個main來代替。您需要更改項目設置(如「控制檯應用程序」的行),或者使用WinMain來代替。你可能想要前者。

注意,WinMain不是標準配置。這只是Windows的聯動要求。

2

(這是一個duplicate?)

你可以讓你的主,但查找選項

--subsystem,windows -mwindows 
文檔中

您MinGW的C++編譯器。

1

確保你至少有主。我通過提供主要功能來解決我的問題。編譯時我沒有。我在Windows上......似乎默認情況下它試圖尋找winmain。

相關問題