[英]How to overcome error while compiling gtk programs in windows?
i have installed gtk and mingw in windows and compile the program with the following command 我已经在Windows中安装了gtk和mingw,并使用以下命令编译程序
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%
and i have got the following error 我有以下错误
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
I agree with the spacing issue, should be -lgio-2.0 -lpangowin32-1.0
, not -lgio-2.0-lpangowin32-1.0
. 我同意间距问题,应该是
-lgio-2.0 -lpangowin32-1.0
,而不是-lgio-2.0-lpangowin32-1.0
。 If you still have a similar error, check the libs not found are available in the directories you passed to gcc with the -L
option (ie. C:/Windows/gtk+-bundle/lib
) 如果仍然有类似的错误,请使用
-L
选项检查传递给gcc的目录中是否存在未找到的库(例如C:/Windows/gtk+-bundle/lib
)。
BTW, prefer the syntax advised by GTK , it prevents copy/pasting issues: 顺便说一句,更喜欢GTK建议的语法 ,它可以防止复制/粘贴问题:
gcc $(pkg-config --cflags --libs gtk+-2.0) hello.c -o hello
You may need to add pkg-config
to your PATH
, and maybe the directory where your .pc files are to PKG_CONFIG_PATH
. 您可能需要将
pkg-config
添加到PATH
,也可能需要将.pc文件的目录添加到PKG_CONFIG_PATH
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.