1
edit
Changes
→TextEdit: Member Assignment: Added GNU Make script for project
** N/A
===Makefile===
Create a file called ''makefile'' and copy the following code into it.
<big><syntaxhighlight lang="make">
# Simple Makefile for GNU Make
# Date Written: March 25, 2010
# Date Updated: N/A
# C++ compiler flags(eg. -g = Enable Debugger)
CXXFLAGS = -g
# Enter C++ soucre file names but with *.o as file extension
# (eg. SourceFile.cpp = SourceFile.o)
OBJS = SourceFile.o
# Specfiy any library that are used in the program but not defind
# in $PATH
LIBS = /lib/libncurses.so.5
# Specfiy output filename of the program
TARGET = output_file
# DO NOT CHANGE ANYTHING BELOW HERE #
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
clean:
rm $(OBJS) $(TARGET)
</syntaxhighlight></big>
To compile type ''make'' on the command line where the makefile and *.cpp source files are. To clean the project and remove all the object files and program file type ''make clean''. Note it's not necessary to type ''make clean'' and ''make'' every time you change code in the source file. Just type ''make'' and GNU Make will compare the source files with the object files and only compile and link the files that have been edited.
[[Category:OOP344]]