Compiling and running GTK+ application on Windows 7

后端 未结 3 540
独厮守ぢ
独厮守ぢ 2020-12-10 00:05

System: Windows7, 32 bit, GTK 2.24.10, mingw
I am trying to write basic helloworld.c type GTK based application. However, it doesn\'t run.
These are the steps which

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 00:37

    You could try these manual steps to start with:

    1) At your command prompt run the pkg-config command to get your include flags:

    c:\dev\gtk224\bin\pkg-config.exe --cflags gtk+-2.0

    This is my output:

    -mms-bitfields -Ic:/dev/gtk224/include/gtk-2.0 -Ic:/dev/gtk224/lib/gtk-2.0/include -Ic:/dev/gtk224/include/atk-1.0 -Ic:/dev/gtk224/include/cairo -Ic:/dev/gtk224/include/gdk-pixbuf-2.0 -Ic:/dev/gtk224/include/pango-1.0 -Ic:/dev/gtk224/include/glib-2.0 -Ic:/dev/gtk224/lib/glib-2.0/include -Ic:/dev/gtk224/include -Ic:/dev/gtk224/include/freetype2 -Ic:/dev/gtk224/include/libpng14
    

    2) set the output from (1) to a variable GTK_INCLUDES:

    C:\dev\1_repo\gtk_scratch>set GTK_INCLUDES=-mms-bitfields -Ic:/dev/gtk224/include/gtk-2.0 -Ic:/dev/gtk224/lib/gtk-2.0/include -Ic:/dev/gtk224/include/atk-1.0 -Ic:/dev/gtk224/include/cairo -Ic:/dev/gtk224/include/gdk-pixbuf-2.0 -Ic:/dev/gtk224/include/pango-1.0 -Ic:/dev/gtk224/include/glib-2.0 -Ic:/dev/gtk224/lib/glib-2.0/include -Ic:/dev/gtk224/include -Ic:/dev/gtk224/include/freetype2 -Ic:/dev/gtk224/include/libpng14
    

    (make sure you use YOUR output from step (1))

    3) do the same as step 1 for the library flags:

    c:\dev\gtk224\bin\pkg-config.exe --libs gtk+-2.0

    This is my output:

    -Lc:/dev/gtk224/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
    

    4) set output from (3) to a variable GTK_LIBS

    C:\dev\1_repo\gtk_scratch>set GTK_LIBS=-Lc:/dev/gtk224/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
    

    (make sure you use YOUR output from step (3))

    5) make sure gtk+ and MinGW are on your path:

    set PATH=c:\dev\MinGW\bin\;c:\dev\gtk224\bin
    

    (make sure you set your path to YOUR mingw and gtk directories)

    6) compile:

    c:\dev\MinGW\bin\gcc.exe -g helloworld.c -o helloworld %GTK_INCLUDES% %GTK_LIBS%
    

    7) when you are able to compile OK, copy what you did in steps 2,4,5 and 6 to a batch file so can compile you app just by running the batch file.

提交回复
热议问题