C++ “没有可用的来源”;main();c+的错误+;日蚀
我知道以前有很多人问过这个问题,但我一直没能解决。我想在eclipse中调试makefile项目,但我不能。我刚学C++,不知道怎么写Mag文件,但是我的老师给我一个用,我已经把它贴在下面了。如何修复此错误 另外,如果这对你们有帮助的话,我只想调试DijkstraTest.cpp主函数,而不是其他任何函数C++ “没有可用的来源”;main();c+的错误+;日蚀,c++,eclipse,debugging,C++,Eclipse,Debugging,我知道以前有很多人问过这个问题,但我一直没能解决。我想在eclipse中调试makefile项目,但我不能。我刚学C++,不知道怎么写Mag文件,但是我的老师给我一个用,我已经把它贴在下面了。如何修复此错误 另外,如果这对你们有帮助的话,我只想调试DijkstraTest.cpp主函数,而不是其他任何函数 # first name a variable objects for all object files # FOR strauss #CXX = CC objectsqueue = Lin
# 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)
为了能够调试应用程序,您需要使用
-g
(调试)标志对其进行编译:
所有编译规则都需要使用此标志。代码中是否有main()?是的,我的每个test.cpp文件中都有一个。应该只有1个
main
函数。您是否在编译器或链接器的命令行中包含了test.cpp
文件?不,我不知道该怎么做。我已经删除了另外两个带有主要函数的测试文件,但是没有什么区别
CXXFLAGS=-g
$(objectsqueue): $(sourcesqueue)
$(CXX) $(CXXFLAGS) -c $(sourcesqueue) $(INCLUDES)
...
testqueue: $(objectsqueue) $(objectstestqueue)
$(CXX) $(CXXFLAGS) -o QueueTests.exe $(objectsqueue) $(objectstestqueue)
....