2

I have Fedora (latest) installed as well as mingw32 and gtk packages.

I wrote simple Hello world:

#include <gtk/gtk.h>

int main(int argc, char* argv[]){
    GtkWidget *window;

    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_show(window);

    gtk_main();

    return 0;
}

I can easily compile it under Fedora with:

gcc -o hello hello.c 'pkg-config --libs --cflags gtkmm-3.0'

(wrong apostrophes here)

I also tried to compile simple printf("Hello world"); program (without gtk) for windows with: i686-pg-mingw32-gcc simple.c -o simple.exe and it worked perfectly under Windows

But what I can´t is cross-compile for windows using GTKmm (even example with another version of GTK would be great). I read this http://camltastic.blogspot.com/2008/10/mingw-compile-software-for-windows.html but it uses configure and make which I don´t have for my programs.

Also there´s a lot there: http://ricardo.ecn.wfu.edu/~cottrell/cross-gtk/ but it talks about installing mingw yourself to custom folder and so... but I have installed mingw using Fedora yum.

Update

Update after all rodrigo's tips:

YES! We got it! It's working. It's starting console first but nevermind. I also haven't tested all GTK libraries, but I think they should work as well.

After year of trying I finally have it and I am closest to developing GUI apps ever I've ever been. So thank you a lot for your patience and guidance. I think that now I also somehow understood how this all works (I mean, compiled libs for different OS, pkg-config, passing variables etc.)

halfer
  • 19,824
  • 17
  • 99
  • 186
PhoenixS
  • 1,016
  • 1
  • 9
  • 23
  • Extra tip: you can remove the console passing `-mwindows` (default is `-mconsole`) to the linker command. But personally I find it useful in debug builds to see GLIB warnings and other outputs. – rodrigo Dec 05 '11 at 08:58

1 Answers1

1

You have installed mingw from the Fedora repositories, but you still need the GTK libraries compiled for Windows. You can compile them yourself (not trivial, but not terribly difficult either) or you can download them elsewhere, as the page you cite suggests.

UPDATE: About your tries in the comments below:

I fixed pc files I copied into /usr/lib/pkgconfig and here is my log: pastebin.com/KZr8tMQ0 I really don't understand. When I run pkg-config it's missing gobject. When I run it as root it's missing gdk. When I run it with gtkmm-3.0 it generates parameters...when I run it with gtkmm-2.4 it crash even if gtkmm-2.4 is actualy the only gtkmm pc file I have in folder set in PKG_CONFIG_PATH.

  • You don't have gtk-3.0 nor gtkmm-3.0 for Windows. So it is no surprise that it says: Package gtkmm-3.0 was not found in the pkg-config search path. Use pkg-config gtkmm-2.4 .
  • You have gtkmm-2.4 & friends for Windows but you lack gtk+-2.0 (no gtk+-2.0.pc file) and all its dependencies (pango, cairo, gdk, atk, glib...).
  • You should not run pkg-config or the compiler using sudo. Sudo does not forward most environment variables for security reasons. That's why sudo pkg-config is ignoring your Windows installation.
  • Lastly, PKG_CONFIG_PATH is for adding additional paths to search for .pc files. If all your files are in the same directory, setting PKG_CONFIG_LIBDIR is enough, but you are setting it wrong, it should be to the lib/pkgconfig directory.
rodrigo
  • 94,151
  • 12
  • 143
  • 190
  • OK - so it seems like I have to download GTKmm and compile it for windows. Because suggested site http://www.gimp.org/~tml/gimp/win32/downloads.html is down. Here (http://live.gnome.org/gtkmm/MSWindows) is only exe installer. So I have to use this sources http://ftp.gnome.org/pub/GNOME/sources/gtkmm/3.3/ and this manual http://live.gnome.org/gtkmm/MSWindows/BuildingGtkmm to creata GTKmm windows version myself? And after done...how will I use it to create my apps? – PhoenixS Dec 03 '11 at 08:47
  • If you want to use `pkg-config` as in the example, just export the `PKG_CONFIG_PATH` environment variable to point to where the *.pc files for Windows are. For example, in my installation I have `PKG_CONFIG_LIBDIR=$HOME/mingw/sysroot/mingw/lib/pkgconfig`. Then running `i686-pg-mingw32-g++ -o test-gtk test-gtk.cpp 'pkg-config --libs --cflags gtkmm-3.0'` will just work. – rodrigo Dec 03 '11 at 09:45
  • So I downloaded GTKmm installer for Windows, installed it on windows and then copied entire folder to Fedora. I have 9 .pc files in ./lib/pkgconfig of GTKmm installation. I couldn´t persuade pkg-config to use pc files from this folder (though I set PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR variables) so I copied these .pc files to /usr/lib/pkgconfig (that´s where its getting files from), but when I now try to run pkg-config by: sudo pkg-config --libs --cflags gtkmm-3.0 it´s geeting me "Package 'gdkmm' requires 'pangomm-1.4 >= 2.27.1' but version of Pangomm is 2.8.8" error – PhoenixS Dec 03 '11 at 11:08
  • Don't do that! You are mixing *.pc files for the native and cross compiler environments. What will break badly! Exporting PKG_CONFIG_LIBDIR should work. If not, try executing pkg-config manually and posting the results. And maybe you'll have to edit the .pc files to change the installation prefix. – rodrigo Dec 03 '11 at 11:31
  • I fixed pc files I copied into /usr/lib/pkgconfig and here is my log: http://pastebin.com/KZr8tMQ0 I really don't understand. When I run `pkg-config` it's missing `gobject`. When I run it as root it's missing `gdk`. When I run it with `gtkmm-3.0` it generates parameters...when I run it with `gtkmm-2.4` it crash even if gtkmm-2.4 is actualy the only gtkmm pc file I have in folder set in `PKG_CONFIG_PATH`. – PhoenixS Dec 03 '11 at 12:37
  • It seeems like almost done! I fixed LIBDIR (was setting it that way because of confused by pkg-config man) and added all GTK+ files for Win to folder I use and now pkg-config is generating real [amount of text](http://pastebin.com/ZjA1TwCP) but I don't understand all those hashcodes or whatever it is? Now, when I run `i686-pc-mingw32-g++ -o test-gtk.exe hello.c 'pkg-config --cflags --libs gtkmm-2.4'` it writes: 'hello.c:1:21 fatal error: gtk/gtk.h: No such file or directory'. Hello.c is [here](http://pastebin.com/pSsip1MW) – PhoenixS Dec 04 '11 at 17:39
  • Now we are getting to it. Now you have to hand-edit the .pc until the `-I` options refer to you header directories and the `-L` options refer to the library directories. Usually, if you copied the whole directory structure from Windows, it is enough if you change the `prefix` lines. – rodrigo Dec 04 '11 at 17:54
  • It' s still saying the same error, but now my pkg-config output looks like [this](http://pastebin.com/qgqSXnzr). I Wasn't sure, whether I have to change `/target` for full path to folder with GTK or I have to leave it there. – PhoenixS Dec 04 '11 at 21:14
  • The arguments to the `-I` and `-L` options should be the full paths to where the relevant files are stored. So, yes, you should change `/target` into `/home/michal/Dropbox/GTK/GTKmm-Devel` or whatever. – rodrigo Dec 04 '11 at 22:13
  • I changed the `/target` for full path and in update of my answer you can see what happened :-) – PhoenixS Dec 05 '11 at 05:48