2012-04-18 78 views
0

我已经安装了GTK和MinGW在Windows和使用下面的命令在Windows中编译gtk程序时如何克服错误?

set VAR=-mms-bitfields -IC:/Windows/gtk+-bundle/include/gtk-2.0 -IC:/Windows/gtk+-bundle/lib/gtk-2.0/include -IC:/Windows/gtk+-bundle/include/atk-1.0 -IC:/Windows/gtk+-bundle/include/cairo -IC:/Windows/gtk+-bundle/include/gdk-pixbuf-2.0 -IC:/Windows/gtk+-bundle/include/pango-1.0 -IC:/Windows/gtk+-bundle/include/glib-2.0 -IC:/Windows/gtk+-bundle/lib/glib-2.0/include -IC:/Windows/gtk+-bundle/include -IC:/Windows/gtk+-bundle/include/freetype2 -IC:/Windows/gtk+-bundle/include/libpng14 -LC:/Windows/gtk+-bundle/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 

    gcc a.c %VAR% 

编译程序,我已经得到了以下错误

C:\Users\kiran\Desktop\gtk>gcc a.c -mms-bitfields -IC:/Windows/gtk+-bundle/inclu 
de/gtk-2.0 -IC:/Windows/gtk+-bundle/lib/gtk-2.0/include -IC:/Windows/gtk+-bundle 
/include/atk-1.0 -IC:/Windows/gtk+-bundle/include/cairo -IC:/Windows/gtk+-bundle 
/include/gdk-pixbuf-2.0 -IC:/Windows/gtk+-bundle/include/pango-1.0 -IC:/Windows/ 
gtk+-bundle/include/glib-2.0 -IC:/Windows/gtk+-bundle/lib/glib-2.0/include -IC:/ 
Windows/gtk+-bundle/include -IC:/Windows/gtk+-bundle/include/freetype2 -IC:/Wind 
ows/gtk+-bundle/include/libpng14 -LC:/Windows/gtk+-bundle/lib -lgtk-win32-2.0 - 
lgdk-win32-2.0 -latk-1.0 -lgio-2.0-lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgd 
k_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lgli 
b-2.0 -lintl 
C:\Windows\MinGW\bin/ld.exe: cannot find -lgio-2.0-lpangowin32-1.0 
collect2: ld returned 1 exit status 
+0

嗯,你试过在“-lgio-2.0-lpangowin32-1.0 ”之间放置一个空格在你的参数中吗?正如在“-lgio-2.0 [SPACE] -lpangowin32-1.0” – Ancurio 2012-04-18 11:12:22

+0

thats correct.but我已经得到了整个命令通过pkg-config --cflags --libs gtk + -2.0 – 2012-04-18 11:59:30

回答

0

我同意的间距问题,应该是-lgio-2.0 -lpangowin32-1.0,不是-lgio-2.0-lpangowin32-1.0。如果您仍然有类似的错误,检查没有发现库在目录提供你通过与-L选项(即C:/Windows/gtk+-bundle/lib

BTW到GCC,喜欢syntax advised by GTK,它可以防止复制/粘贴问题:

gcc $(pkg-config --cflags --libs gtk+-2.0) hello.c -o hello 

您可能需要将pkg-config添加到您的PATH,也可能是.pc文件的目录为PKG_CONFIG_PATH