Skip to main content

A Simple Makefile for a GTK/GTKMM Project

When compiling small applications, its fairly easy just to compile using g++ from the command line. If you’re compiling anything more complex than a single file, its probably easier to use a Makefile. This example Makefile demonstrates how to compile an application that uses the GTKMM library.

NAME=my-app
CFLAGS=-g -Wall -o $(NAME)
GTKFLAGS=`pkg-config --cflags --libs gtkmm-3.0`
SRCS=main.cc myapp.cc
CC=g++
  
# Do all
all: main
  
# Compile
main: $(SRCS)
    $(CC) $(CFLAGS) $(SRCS) $(GTKFLAGS)
  
# Clean
clean:
    rm -f $(NAME)
    rm -f *.h~
    rm -f *.cc~
    rm -f Makefile~
    rm -f *.glade~

Comments