Eclipse中c ++的“main()”错误没有可用的源代码

时间:2012-11-26 23:25:52

标签: c++ eclipse debugging

我知道很多人之前已经问过这个,但是我无法解决它。我想在eclipse中调试一个makefile项目,但我不能。我只是在学习c ++,不知道如何编写makefile,但我的老师给了我一个使用,我在下面发布了它。我该如何解决这个错误?

另外,如果它对你们有任何帮助,我只想调试DijkstraTest.cpp主要功能,而不是其他任何功能。

# first name a variable objects for all object files
# FOR strauss
#CXX = CC

objectsqueue = LinkedList.o

objectstestqueue = QueueTests.o

objectsheap = BinaryHeap.o

objectstestheap = BinaryHeapTest.o

objectsdijkstra = CSV.o Network.o Dijkstra.o

objectstestdijkstra = DijkstraTest.o

# name a variable sources for all source files

sourcesqueue = LinkedList.cpp

sourcestestqueue = QueueTests.cpp

sourcesheap = BinaryHeap.cpp

sourcestestheap = BinaryHeapTest.cpp

sourcesdijkstra = CSV.cpp Network.cpp Dijkstra.cpp

sourcestestdijkstra = DijkstraTest.cpp

# now make default target all exe files
all: testqueue testheap testdijkstra

# list the dependencies for object files - those header files which help build objects
LinkedList.cpp: Collection.h Stack.h Queue.h
QueueTests.o: QueueTests.cpp LinkedList.cpp
BinaryHeap.o: BinaryHeap.h 
BinaryHeapTest.o: BinaryHeap.h 
Dijkstra.o: CSV.h Dijkstra.h Network.h BinaryHeap.h 

# how to build all object files from all dependent source files

$(objectsqueue): $(sourcesqueue)
$(CXX) -c $(sourcesqueue) $(INCLUDES)

$(objectstestqueue): $(sourcestestqueue)
$(CXX) -c $(sourcestestqueue) $(INCLUDES)

$(objectsheap): $(sourcesheap)
$(CXX) -c $(sourcesheap) $(INCLUDES)

$(objectstestheap): $(sourcestestheap)
$(CXX) -c $(sourcestestheap) $(INCLUDES)

$(objectsdijkstra): $(sourcesdijkstra)
$(CXX) -c $(sourcesdijkstra) $(INCLUDES)

$(objectstestdijkstra): $(sourcestestdijkstra)
$(CXX) -c $(sourcestestdijkstra) $(INCLUDES)

clean:
rm -f *.o
rm -f *.exe

testqueue:  $(objectsqueue) $(objectstestqueue)
$(CXX) -o QueueTests.exe $(objectsqueue) $(objectstestqueue)

testheap: $(objectsheap) $(objectstestheap) 
$(CXX) -o BinaryHeapTest.exe $(objectsheap) $(objectstestheap)

testdijkstra: $(objectsheap) $(objectsdijkstra) $(objectstestdijkstra) 
$(CXX) -o DijkstraTest.exe $(objectsheap) $(objectsdijkstra) $(objectstestdijkstra)

1 个答案:

答案 0 :(得分:1)

为了能够调试应用程序,您需要使用-g(调试)标志来编译它:

CXXFLAGS=-g

$(objectsqueue): $(sourcesqueue)
$(CXX) $(CXXFLAGS) -c $(sourcesqueue) $(INCLUDES)

...

testqueue:  $(objectsqueue) $(objectstestqueue)
$(CXX) $(CXXFLAGS) -o QueueTests.exe $(objectsqueue) $(objectstestqueue)

....

您需要将此标志用于所有编译规则。