Skip to content

Instantly share code, notes, and snippets.

@VeggieVampire
Last active July 9, 2018 07:54
Show Gist options
  • Save VeggieVampire/b7cade7f3d95d6b99a01748eabe9cff4 to your computer and use it in GitHub Desktop.
Save VeggieVampire/b7cade7f3d95d6b99a01748eabe9cff4 to your computer and use it in GitHub Desktop.
Basic Perfect Makefile for compiling target .cpp files using g++.
Basic Perfect Makefile for compiling target .cpp files with SDL2 libraries using g++.
#USEAGE: copy Makefile to folder with .cpp files then type "make"
#OBJS specifies which files to compile as part of the project
OBJS = $(wildcard *.cpp)
#CC specifies which compiler we're using
CC = g++
#COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings
COMPILER_FLAGS = -w
#LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS = -lSDL2 -lSDL2_image
#OBJ_NAME specifies the name of our exectuable
OBJ_NAME = $(patsubst %.cpp,%,$(wildcard *.cpp))
#This is the target that compiles our executable
all : $(OBJS)
$(CC) $(OBJS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)
@VeggieVampire
Copy link
Author

Tested on raspberry pi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment