第一个GTK程序

source code


#include 

int main(int argc, char* argv[])
{
    GtkWidget * window;
    
    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "Hello World");
    gtk_widget_show(window);
    
    gtk_main();
    
    return 0;
}

 

makefile

EXE    = gtk_test
CC     = gcc
SRC    = $(wildcard *.c)
OBJ    = $(SRC:.c=.o)

GTK_LIBS = $(shell (pkg-config --libs gtk+-2.0))
GTK_CFLAGS = $(shell (pkg-config --cflags gtk+-2.0))

INCLUDES = -I/mingw32/include/glib-2.0/ \
           -I/mingw32/lib/glib-2.0/include/ 

LIBS     = -L/mingw32/lib/ -lglib-2.0 $(GTK_LIBS)

CFLAGS = -g -O2 -Wall $(INCLUDES) $(GTK_CFLAGS)

all:$(EXE)

$(EXE): $(OBJ)
	$(CC) $(OBJ) $(LIBS) -o $@
	
clean:
	@rm $(EXE) $(OBJ) -f

效果

第一个GTK程序_第1张图片

退出:

ctrl + 'c'

你可能感兴趣的:(GTK2.0)