Skip to content

Instantly share code, notes, and snippets.

@gzmask
Created March 11, 2010 21:18
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gzmask/329661 to your computer and use it in GitHub Desktop.
Save gzmask/329661 to your computer and use it in GitHub Desktop.
OpenGL cross platform makefile
$ make
gcc -o hello hello.c -lGL -lGLU -lglut
ld: library not found for -lGL
collect2: ld returned 1 exit status
make: *** [hello] Error 1
# Linux (default)
EXE = hello
LDFLAGS = -lGL -lGLU -lglut
# Windows (cygwin)
ifeq ($(OS), "Windows_NT")
EXE = hello.exe
LDFLAGS = -lopengl32 -lglu32 -lglut32
endif
# OS X
ifeq ($(OSTYPE), "darwin9.0")
LDFLAGS = -framework Carbon -framework OpenGL -framework GLUT
endif
$(EXE) : hello.c
gcc -o $@ $< $(CFLAGS) $(LDFLAGS)
# Linux (default)
EXE = hello
LDFLAGS = -lGL -lGLU -lglut
# Windows (cygwin)
ifeq ($(OS), "Windows_NT")
EXE = hello.exe
LDFLAGS = -lopengl32 -lglu32 -lglut32
endif
# OS X
ifeq "$(shell uname)" "Darwin"
LDFLAGS = -framework Carbon -framework OpenGL -framework GLUT
endif
$(EXE) : hello.c
gcc -o $@ $< $(CFLAGS) $(LDFLAGS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment