簡體   English   中英

在Windows中編譯gtk程序時如何克服錯誤?

[英]How to overcome error while compiling gtk programs in windows?

我已經在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%

我有以下錯誤

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

我同意間距問題,應該是-lgio-2.0 -lpangowin32-1.0 ,而不是-lgio-2.0-lpangowin32-1.0 如果仍然有類似的錯誤,請使用-L選項檢查傳遞給gcc的目錄中是否存在未找到的庫(例如C:/Windows/gtk+-bundle/lib )。

順便說一句,更喜歡GTK建議語法 ,它可以防止復制/粘貼問題:

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

您可能需要將pkg-config添加到PATH ,也可能需要將.pc文件的目錄添加到PKG_CONFIG_PATH

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM