I've been searching for days and reading about using makefiles on linux and I cannot, for the life of me, get it to work correctly.
Let's say I have three files: Finances.cpp Parse.cpp and Parse.h
Finances.cpp has several calls to a function named parse whose definition is in Parse.cpp. Finances.cpp includes Parse.h which contains the prototype of the function named parse.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
CXXFLAGS = -O2 -g -Wall
OBJS = Finances.o
LIBS =
TARGET = Finances
Finances: Finances.o
$(CXX) $(CXXFLAGS) -o Finances Finances.o
Finances.o: Parse.h Parse.cpp
$(CXX) -c Finances.cpp
all: Finances
clean:
rm -f $(OBJS) $(TARGET)
| |
I know this is not correct, but this is one of the millions of variations I have tried. What's odd is that if I were to replace the prototype in Parse.h with the definition from Parse.cpp, it works perfectly fine.
I keep getting undefined reference to 'main' or 'parse' errors.
Could someone please point me in the right direction?
If it helps, my OS is Ubuntu 12.04 LTS (Precise Pangolin) 32-bit, my IDE is Eclipse, and my compiler is g++ 4.6.3 (I think?)