The following is a basic makefile that worked for me. However, there’s a link at the bottom to a forum post that provides a better solution.
#The c++ compiler you'd like to use: CC=g++ #the following is for normal use: CFLAGS=-c -O3 -Wall LDFLAGS= #the following is for using gprof or valgrind (only comment out one at a time) #CFLAGS=-g -pg -c -O3 -Wall #LDFLAGS=-pg #All your .cpp files go below. This simple example assumes they're all in the same directory: SOURCES=calculations.cpp Dates.cpp Demands.cpp triangleSimulation.cpp OBJECTS=$(SOURCES:.cpp=.o) #Below you place your target name, what you want the program to be called. EXECUTABLE=triangleSimulation all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@ .cpp.o: $(CC) $(CFLAGS) $^ -o $@ clean: rm -rf *.o $(EXECUTABLE)