Skip to content

Instantly share code, notes, and snippets.

@jayzhan211
Created February 10, 2021 02:56
Show Gist options
  • Save jayzhan211/cdfcf84465405d3316dfe0e72f53d769 to your computer and use it in GitHub Desktop.
Save jayzhan211/cdfcf84465405d3316dfe0e72f53d769 to your computer and use it in GitHub Desktop.
Makefile for one cpp file
TARGET = main
CXXFLAGS = -g -std=c++17 -O2
OBJS = ${TARGET}.o
main: ${OBJS}
${CXX} ${CXXFLAGS} $< -o $@
%.o : %.cpp
${CXX} -c ${CXXFLAGS} $< -o $@
.PHONY: clean
clean:
${RM} *.o *~ ${TARGET}
@jayzhan211
Copy link
Author

prerequisite: cpp file name is main.cpp
make to compile
make clean to remove output files

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