I suggest using a Makefile like this. You'll have to replace the spaces with tabs.
Code:
OBJECTS = swara.o synth.o unit.o sinewave.o
LDFLAGS = -lstdc++ -lportaudio -lsndfile
TARGET = Swara
# Default target: all
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o $(TARGET) $(LDFLAGS)
# Source files
swara.o: swara.cpp swara.hpp
synth.o: synth.cpp synth.hpp
unit.o: unit.cpp unit.hpp
sinewave.o: sinewave.cpp sinewave.hpp
Make has built-in rules that automatically know how to build .c, .cpp, and other source files.
The blue code can be automatically generated (with the proper dependencies) with
Also see matsp's suggestions.
And you might perhaps want some targets like this:
Code:
clean:
rm $(OBJECTS) $(TARGET)
run: $(TARGET)
$(TARGET)
debug: $(TARGET)
gdb $(TARGET)
Finally, if you want to set a breakpoint or whatever on line 80 of a different file from the current one in gdb, use
Code:
(gdb) break otherfile.cpp:80
GDB has a pretty extensive help system. You can type help or help breakpoints etc to get more information. And there's always some online manuals and tutorials for gdb. (One on this very site.)
[edit] Oh yes, and if you create a file called, say, all, then the all target won't work properly. You'll have to add
Code:
.PHONY: all clean run
etc if you create files by those names. [/edit]