What are the pre-requisite SW needed for building gtk-fortran ? When I try this
gfortran `pkg-config --cflags --libs gtk+-2.0` ./gtkhello2.f90
I get the following error:
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
Fatal Error: Can't open module file 'gtk.mod' for reading at (1): No such file or directory
I'm using Ubuntu 10.10 (Maverick). I tried to install "libgtk-2.0-dev" but it seems to pull along a whole lot of baggage (~ 46 packages to be installed for libgtk-2.0-dev to work !). The non-dev version is already installed. I'm not willing to waste > 100 MB space just to compile 2 *.f90 files. So, I was wondering if there is a simpler / easier way.
Hi, try to compile with:
gfortran pkg-config --cflags --libs gtk+-2.0 ./gtkhello2.f90 ../src/gtk.f90
pkg-config --cflags --libs gtk+-2.0
Note that you will probably need gfortran 4.6.0 (devel. version):
Even in gfortran 4.5 there was a bug preventing to compile those examples.
The GTK+ version is 2.22 (I also work under Ubuntu 10.10).
I think you really need to install "libgtk-2.0-dev" to compile and link any Fortran program using GTK+. And when you first install a dev package, a lot of other package are needed to allow compiling/linking.
But Jerry will surely give you more details about that.
What I have learned just tonight is that one need a recent version of gfortran 4.6 to compile. At least a few months ago version does not work from a compiler bug now fixed.
Yes you do need the dev packages for gtk+2.0 installed also.
Thanks Jerry and Vincent. I installed the "dev" packages & very happy to see the Hello World program ! Also works fine with Intel Fortran 12.0.0 on x86-ubuntu-maverick, it took a long time to compile (~10 minutes) but GFortran was fast. I'll probably start writing some examples, similar to those in GTK tutorial. And many thanks for the wiki page, is very helpful !
thank you for your help. The information about Linux Intel Fortran is interesting. First because it works, secondly because it is so long to compile. I suppose you used the gtk.f90 file in the devel branch, which is becoming quite big. When I use gfortran under linux it takes around 20 seconds to compile. But gfortran under Windows 7 takes also 5 to 10 minutes ! Why so huge differences ? There is something interesting here about the functioning of compilers. I am not a specialist but perhaps Jerry has something to tell about this problem.
We have to think about the possibility of dividing the gtk-auto.f90 into several smaller files. Compiling would be faster but we would have to choose which module we need to use in each program. I am opened on that question (technically it is easy, the script has already the functionality to do this).
Another solution to compile fast is to delete the include "gtk-auto.f90" statement in gtk.f90 and copy from gtk-auto.f90 only the interfaces of the GTK+ functions you need in your program.
Is there some logical way to break these up into perhaps multiple module files? and do so in a way that there are no inter-dependencies
It is possible to split gtk-auto following the headers directories.
All the header files of GTK+ = 3.4 Mio:
"/usr/include/gtk-2.0/gdk": 345 Kio
"/usr/include/gtk-2.0/gtk": 1.3 Mio
"/usr/include/cairo": 130 Kio
"/usr/include/pango-1.0": 175 Kio
"/usr/include/glib-2.0": 1.3 Mio ("gio": 589 Kio, "glib": 439 Kio, "gobject": 239 Kio)
"/usr/include/gdk-pixbuf-2.0": 59 Kio
"/usr/include/atk-1.0": 171 Kio
But note that the gtk directory is the biggest (1.3 Mio) and will generally always be required. So the compiling time would be smaller but still long.
We could also have a smaller granularity by grouping gtk header files into several modules.