Makefile for GTK2 programs?
What CFLAGS and LIBS I should use in Makefiles? I installed GTK2 to home directory, and thus I won't use lddconfig. My programs should take all from ~/gtk2/, and nothing from /usr/include/gtk-1.2/ and nothing gtk-related from /usr/lib/. GTK2 does not have gtk-config program. It made things easier in gtk1.2: CC=gcc -O2 -Wall CFLAGS = `gtk-config --cflags` LIBS= `gtk-config --libs` -lm -ljpeg -lpng Is there away to get all CFLAGS and LIBS by checking the pkgconfig file? ~/gtk2/lib/pkgconfig/gtk+-2.0.pc I have now the following in Makefile. Very messy. It does not work; I get errors: undefined reference to `gtk_text_view_new' and the like. CC=gcc -O2 -Wall CFLAGS= -I/home/juhana/gtk2/include/glib-2.0 -I/home/juhana/gtk2/include/gtk-2.0 -I/home/juhana/gtk2/lib/glib-2.0/include -I/home/juhana/gtk2/include/cairo -I/home/juhana/gtk2/include/pango-1.0 -I/home/juhana/gtk2/lib/gtk-2.0/include -I/home/juhana/gtk2/include/atk-1.0 LIBS= -L/home/juhana/gtk2/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm -ljpeg -lpng O_ESPBROWSER=mylib/filesdirs.o mylib/buffer.o mylib/image.o mylib/gsl_taus.o mylib/clock.o mylib/mmapfile.o mylib/sprint.o mylib/arrays.o espbrowser.o all:: espbrowser espbrowser: $(O_ESPBROWSER) $(CC) $(CFLAGS) -o espbrowser $(O_ESPBROWSER) $(LIBS) I use this include command in the C code: #include "/home/juhana/gtk2/include/gtk-2.0/gtk/gtk.h" I'm afraid it won't help because gtk.h uses #include which may be "/usr/include/gtk-1.2/gdk/gdk.h". How the linked ld works? My programs are simple. Perhaps I could write a script to compile and link everything explicitly. But this include file business worries me still. This is so frustating. I will return to GTK 1.2 soon. First Ubuntu failed to install GTK2, and now this! I could start writing my programs under demos/gtk-demo/ and compile the demo. But then I don't understand how to add my mylib/mmapfile.o etc. files to the configure system. :-( Help needed. ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Makefile for GTK2 programs?
Le mercredi 18 août 2010 à 10:26 +0300, Juhana Sadeharju a écrit : > What CFLAGS and LIBS I should use in Makefiles? > I installed GTK2 to home directory, and thus I won't use lddconfig. > My programs should take all from ~/gtk2/, and nothing from > /usr/include/gtk-1.2/ and nothing gtk-related from /usr/lib/. > > GTK2 does not have gtk-config program. It made things easier > in gtk1.2: > > CC=gcc -O2 -Wall > CFLAGS = `gtk-config --cflags` > LIBS= `gtk-config --libs` -lm -ljpeg -lpng > > Is there away to get all CFLAGS and LIBS by checking the pkgconfig file? > ~/gtk2/lib/pkgconfig/gtk+-2.0.pc CFLAGS=`PKG_CONFIG_PATH=~/gtk2/lib/pkgconfig:$PKG_CONFIG_PATH pkg-config --cflags gtk+-2.0` LIBS=`PKG_CONFIG_PATH=~/gtk2/lib/pkgconfig:$PKG_CONFIG_PATH pkg-config --libs gtk+-2.0` (you might have to replace ~ by the real path) hope this helps, regards, Jean > > I have now the following in Makefile. Very messy. It does not work; > I get errors: undefined reference to `gtk_text_view_new' and the like. > > CC=gcc -O2 -Wall > CFLAGS= -I/home/juhana/gtk2/include/glib-2.0 > -I/home/juhana/gtk2/include/gtk-2.0 -I/home/juhana/gtk2/lib/glib-2.0/include > -I/home/juhana/gtk2/include/cairo -I/home/juhana/gtk2/include/pango-1.0 > -I/home/juhana/gtk2/lib/gtk-2.0/include -I/home/juhana/gtk2/include/atk-1.0 > LIBS= -L/home/juhana/gtk2/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl > -lXi -lXext -lX11 -lm -ljpeg -lpng > > O_ESPBROWSER=mylib/filesdirs.o mylib/buffer.o mylib/image.o > mylib/gsl_taus.o mylib/clock.o mylib/mmapfile.o mylib/sprint.o mylib/arrays.o > espbrowser.o > > all:: espbrowser > > espbrowser: $(O_ESPBROWSER) > $(CC) $(CFLAGS) -o espbrowser $(O_ESPBROWSER) $(LIBS) > > > I use this include command in the C code: > #include "/home/juhana/gtk2/include/gtk-2.0/gtk/gtk.h" > I'm afraid it won't help because gtk.h uses > #include > which may be "/usr/include/gtk-1.2/gdk/gdk.h". > > > How the linked ld works? My programs are simple. Perhaps I could > write a script to compile and link everything explicitly. But this > include file business worries me still. > > This is so frustating. I will return to GTK 1.2 soon. > First Ubuntu failed to install GTK2, and now this! > > I could start writing my programs under demos/gtk-demo/ and compile > the demo. But then I don't understand how to add my mylib/mmapfile.o > etc. files to the configure system. :-( > > Help needed. > > ___ > gtk-list mailing list > gtk-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Makefile for GTK2 programs?
On Wed, 18 Aug 2010 10:26:45 +0300 Juhana Sadeharju wrote: > This is so frustating. I will return to GTK 1.2 soon. > First Ubuntu failed to install GTK2, and now this! If you are using ubuntu it will already have gtk2 installed, as it depends on it. No distribution has used gtk+-1.2 as the basis of its desktop environment for about 8 to 10 years. You probably just need to install the ubuntu development package containing the gtk2 headers. Chris ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Makefile for GTK2 programs?
On Wed, Aug 18, 2010 at 10:26:45AM +0300, Juhana Sadeharju wrote: > I have now the following in Makefile. Very messy. It does not work; > I get errors: undefined reference to `gtk_text_view_new' and the like. When does the error happen? If it is at run time, you may want to add -Wl,-R/home/juhana/gtk2/lib to LIBS... Cheers, Patrick ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Re: Makefile for GTK2 programs?
On Aug 18, 2010 1:57am, Chris Vine wrote: You probably just need to install the ubuntu development package containing the gtk2 headers. apt-get install libgtk2.0-dev? And maybe libglib2.0-dev? ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list