Nick Nicolini
Nick Nicolini

Reputation: 129

No source available for "main()" error for c++ in Eclipse

I know many people have asked this before but I haven't been able to resolve it. I want to debug a makefile project in eclipse, but I can't. I'm just learning c++ and don't know how to write makefiles, but my teacher gave me one to use, I have posted it below. How can I fix this error?

Also, if it is of any help to you guys, I only want to debug the DijkstraTest.cpp main function, not any of the other ones.

# 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)

Upvotes: 3

Views: 4057

Answers (1)

perreal
perreal

Reputation: 97958

To be able to debug an application, you need to compile it using the -g (debug) flag:

CXXFLAGS=-g

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

...

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

....

you need to use this flag for all compilation rules.

Upvotes: 1

Related Questions