c++ - Help compiling GTK+ on Windows using MinGW -


i on trying compile simple gtk+ hello world app on windows. following tutorial url:

http://pandhare0.tripod.com/#mini-tutorial

the contents of helloworld.c follows , taken wikipedia example:

 #include <gtk/gtk.h>   int main (int argc, char *argv[])  {     gtkwidget *window;     gtkwidget *label;      gtk_init (&argc, &argv);      /* create main, top level, window */     window = gtk_window_new (gtk_window_toplevel);      /* give title */     gtk_window_set_title (gtk_window (window), "hello world");      /* connect destroy signal of window gtk_main_quit      * when window destroyed notification ,      * stop main gtk+ loop      */     g_signal_connect (window, "destroy", g_callback (gtk_main_quit), null);      /* create "hello, world" label  */     label = gtk_label_new ("hello, world");      /* , insert main window  */     gtk_container_add (gtk_container (window), label);      /* make sure everything, window , label, visible */     gtk_widget_show_all (window);      /* start main loop, , let rest there until application closed */     gtk_main ();      return 0;  } 

i have followed instructions generate build bat file , contents of below:

path c:\mingw\bin;c:c:\gtk_2_22_x64\lib\%path%  gcc -wall -g %1 -o %2 -mno-cygwin -mms-bitfields -ic:c:\gtk_2_22_x64\include\gtk-2.0 -ic:c:\gtk_2_22_x64\lib\gtk-2.0\include -ic:c:\gtk_2_22_x64\include\atk-1.0 -ic:c:\gtk_2_22_x64\include\cairo -ic:c:\gtk_2_22_x64\include\gdk-pixbuf-2.0 -ic:c:\gtk_2_22_x64\include\pango-1.0 -ic:c:\gtk_2_22_x64\include\glib-2.0 -ic:c:\gtk_2_22_x64\lib\glib-2.0\include -ic:c:\gtk_2_22_x64\include\pixman-1 -ic:c:\gtk_2_22_x64\include -ic:c:\gtk_2_22_x64\include\freetype2 -ic:c:\gtk_2_22_x64\include\libpng14 -lc:c:\gtk_2_22_x64\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   %2 

i have mingw inside environment path. when run following command inside command prompt:

gtkcmd.bat helloworld.c helloworld.exe 

i following output:

c:\gtk+_compilation>gtkcmd.bat helloworld.c helloworld.exe  c:\gtk+_compilation>path c:\mingw\bin;c:c:\gtk_2_22_x64\lib\c:\mingw\bin;c:c:\gt k_2_22_x64\lib\c:\mingw\bin;c:c:\gtk_2_22_x64\lib\c:\mingw\bin;c:c:\gtk_2_22_x64 \lib\c:\mingw\bin;c:c:\gtk_2_22_x64\lib\c:\mingw\bin;c:\gtk_2_22_x64\lib\c:\ming w\bin;c:\gtk_2_22_x64\lib\c:\program files\common files\microsoft shared\windows  live;c:\program files (x86)\common files\microsoft shared\windows live;c:\windo ws\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspower shell\v1.0\;c:\program files\dell\dell wireless wlan card;c:\program files (x86) \common files\roxio shared\10.0\dllshared\;c:\program files (x86)\common files\r oxio shared\dllshared\;c:\program files\tortoisesvn\bin;c:\program files (x86)\m icrosoft sql server\90\tools\binn\;c:\program files (x86)\windows live\shared;c: \program files (x86)\ironpython 2.7;c:\program files (x86)\microsoft asp.net\asp .net web pages\v1.0\;c:\program files (x86)\gtksharp\2.12\bin;c:\mingw\bin;c:\gt k_2_22_x64\bin;c:\gtk_2_22_x64\lib  c:\gtk+_compilation>gcc -wall -g helloworld.c -o helloworld.exe -mno-cygwin -mms -bitfields -ic:c:\gtk_2_22_x64\include\gtk-2.0 -ic:c:\gtk_2_22_x64\lib\gtk-2.0\i nclude -ic:c:\gtk_2_22_x64\include\atk-1.0 -ic:c:\gtk_2_22_x64\include\cairo -ic :c:\gtk_2_22_x64\include\gdk-pixbuf-2.0 -ic:c:\gtk_2_22_x64\include\pango-1.0 -i c:c:\gtk_2_22_x64\include\glib-2.0 -ic:c:\gtk_2_22_x64\lib\glib-2.0\include -ic: c:\gtk_2_22_x64\include\pixman-1 -ic:c:\gtk_2_22_x64\include -ic:c:\gtk_2_22_x64 \include\freetype2 -ic:c:\gtk_2_22_x64\include\libpng14 -lc:c:\gtk_2_22_x64\lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lp angocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 - lgthread-2.0 -lglib-2.0 -lintl helloworld.c:1:22: fatal error: gtk/gtk.h: no such file or directory compilation terminated.  c:\gtk+_compilation>helloworld.exe 'helloworld.exe' not recognized internal or external command, operable program or batch file.  c:\gtk+_compilation> 

previously had tried, strictly tutorial said, , used / in path statements opposed full paths use. when did use / though not link anything. every gtk statement returned undefined error. have stayed using full path in header , linkers statements in command line. can see above, cannot find gtk/gth.h header. confuses me can see paths such inside command line arguments.

any appreciated.

cheers,

andrew

update:

ok - did screw bat file - daft mistakes after correcting these inline answer below have following bat file:

path \mingw\bin;c:\gtk_2_22_x64\lib\%path%  gcc -wall -g %1 -o %2 -mno-cygwin -mms-bitfields -ic:\gtk_2_22_x64\include\gtk-2.0 -ic:\gtk_2_22_x64\lib\gtk-2.0\include -ic:\gtk_2_22_x64\include\atk-1.0 -ic:\gtk_2_22_x64\include\cairo -ic:\gtk_2_22_x64\include\gdk-pixbuf-2.0 -ic:\gtk_2_22_x64\include\pango-1.0 -ic:\gtk_2_22_x64\include\glib-2.0 -ic:\gtk_2_22_x64\lib\glib-2.0\include -ic:\gtk_2_22_x64\include\pixman-1 -ic:\gtk_2_22_x64\include -ic:\gtk_2_22_x64\include\freetype2 -ic:\gtk_2_22_x64\include\libpng14 -lc:\gtk_2_22_x64\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   %2 

after following errors compilation:

c:\users\rea_an~1\appdata\local\temp\cclrbtyp.o: in function `main': c:\gtk+_compilation/helloworld.c:8: undefined reference `gtk_init_abi_check' c:\gtk+_compilation/helloworld.c:11: undefined reference `gtk_window_new' c:\gtk+_compilation/helloworld.c:14: undefined reference `gtk_window_get_type ' c:\gtk+_compilation/helloworld.c:14: undefined reference `g_type_check_instan ce_cast' c:\gtk+_compilation/helloworld.c:14: undefined reference `gtk_window_set_titl e' c:\gtk+_compilation/helloworld.c:20: undefined reference `gtk_main_quit' c:\gtk+_compilation/helloworld.c:20: undefined reference `g_signal_connect_da ta' c:\gtk+_compilation/helloworld.c:23: undefined reference `gtk_label_new' c:\gtk+_compilation/helloworld.c:26: undefined reference `gtk_container_get_t ype' c:\gtk+_compilation/helloworld.c:26: undefined reference `g_type_check_instan ce_cast' c:\gtk+_compilation/helloworld.c:26: undefined reference `gtk_container_add' c:\gtk+_compilation/helloworld.c:29: undefined reference `gtk_widget_show_all ' c:\gtk+_compilation/helloworld.c:32: undefined reference `gtk_main' collect2: ld returned 1 exit status 

it seems folowed instructions create .bat file incorrectly somehow - this:

-ic:c:\gtk_2_22_x64\include\gtk-2.0 

should be:

-ic:\gtk_2_22_x64\include\gtk-2.0 

and similar elsewhere. looks path has got set incorrectly - this:

path c:\mingw\bin;c:c:\gtk_2_22_x64\lib\%path% 

should be:

path c:\mingw\bin;c:\gtk_2_22_x64\lib\%path% 

or (note c:c: should c:).

edit: , problem linker cannot find libraries. batch file should contain stuff like:

-l/path/to/gtk/libraries 

but don't know how specify when create file.


Comments