Skip to content

Instantly share code, notes, and snippets.

@iKunalChhabra
Last active May 5, 2025 16:58
Show Gist options
  • Save iKunalChhabra/b15545a493b6d81ca2e4c2d99cb1a504 to your computer and use it in GitHub Desktop.
Save iKunalChhabra/b15545a493b6d81ca2e4c2d99cb1a504 to your computer and use it in GitHub Desktop.
Simple c++ makefile
# Makefile
# '@' added to suppress printing commands on shell
# Variables
CXX = g++
CXXFLAGS = -O3
TARGET = main
SRC = main.cpp
# Default target
all: build run
# Build step
build: $(SRC)
@$(CXX) $(CXXFLAGS) -o $(TARGET) $(SRC)
# Run step
run: $(TARGET)
@./$(TARGET)
# Clean step
clean:
@rm -f $(TARGET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment