1 | initial version |
Yes, you can create a makefile to automate the build process. A makefile is a script that automates the building of a program, including compiling, linking, and executing. Here is an example makefile for a simple SDL program:
CC=g++
CFLAGS=-Wall -std=c++11
LIBS=-lSDL2
all: myprogram
myprogram: main.o
$(CC) $(LIBS) $< -o $@
main.o: main.cpp
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f myprogram main.o
To use this makefile, save it as "Makefile" (case-sensitive) in the same directory as your main.cpp file. Then in a terminal, type:
make
./myprogram
This will compile and link the program, producing an executable file called "myprogram", which you can run with the second command. Whenever you make changes to your source code, you can simply run "make" again to recompile and relink the program.