Seems a pain to get started with makefiles for C++ code on Ubuntu.
First create and name the file 'Makefile' in the same folder as your .h and .cpp files
Second copy in the following contents and change the .cpp filenames:
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=Test.cpp Foo.cpp Bar.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=Test
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
Tab $(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
Tab $(CC) $(CFLAGS) $< -o $@
* Standard format is: g++ test1.cpp -o test1
First create and name the file 'Makefile' in the same folder as your .h and .cpp files
Second copy in the following contents and change the .cpp filenames:
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=Test.cpp Foo.cpp Bar.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=Test
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
Tab $(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
* Standard format is: g++ test1.cpp -o test1
Comments
Post a Comment