Skip to content

Instantly share code, notes, and snippets.

@tomdaley92
Last active December 5, 2018 09:38
Show Gist options
  • Save tomdaley92/7d9aafa11255a0b14a2ac2d0d736be1b to your computer and use it in GitHub Desktop.
Save tomdaley92/7d9aafa11255a0b14a2ac2d0d736be1b to your computer and use it in GitHub Desktop.
Build template for Windows C/C++ programs
# Author: Thomas Daley
# Date: September 16, 2016
# Purpose: Build template for Windows C/C++ Programs.
#
# Note: Microsoft Visual C/C++ Build Tools are assumed to be installed and
# added to PATH. The folders "src" and "bin" are expected.
#
# 1) vcvarsall
# 2) nmake
APPNAME = app
CONSOLE_APP = /SUBSYSTEM:CONSOLE
GUI_APP = /SUBSYSTEM:WINDOWS
CC = CL
CFLAGS =
LFLAGS = /link \
/ENTRY:mainCRTStartup
INCS =
LIBS =
# Default target
build: objects
$(CC) $(CFLAGS) /Fe$(APPNAME) $(INCS) *.obj $(LIBS) $(LFLAGS) $(CONSOLE_APP)
DEL *.obj
MOVE $(APPNAME).exe bin/$(APPNAME).exe
objects: src/*.c*
$(CC) $(CFLAGS) /c $(INCS) $(CFLAGS) $?
# Deletes any leftover executables or object files
clean:
DEL $(APPNAME).exe *.obj
cd bin & DEL $(APPNAME).exe
@tomdaley92
Copy link
Author

tomdaley92 commented Nov 12, 2017

project_folder
|---> makefile
|---> bin
|---> src
      |---> main.c

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