且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

编译和运行在Windows上的GTK +应用程序7

更新时间:2022-11-04 14:43:42

您可以尝试以下手动步骤开始:

You could try these manual steps to start with:

1)在你的命令提示符下运行的pkg-config命令,让您的标志包括:

C:\\ dev的\\ gtk224 \\ BIN \\ PKG-config.exe会--cflags GTK + -2.0

这是我的输出:

-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)设置为从输出(1)给一个变量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

(请确保您使用输出步骤(1))

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

3)做相同的库标志步骤1:

C:\\ dev的\\ gtk224 \\ BIN \\ PKG-config.exe会--libs GTK + -2.0

这是我的输出:

-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)设置输出(3)给一个变量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

(请确保您使用输出步骤(3))

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

5)确保GTK +和MinGW是你的路径:

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

(确保你的路径设置为您MinGW和GTK目录)

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

6)编译:

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

7)当你能够编译OK,复制您在步骤2,4,5和6批处理文件这样做可以编译你应用的哪些方面刚刚通过运行批处理文件。