PhoenixS
PhoenixS

Reputation: 1026

Cross-compiling GTK on Fedora using MinGW

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.)

Upvotes: 2

Views: 2386

Answers (1)

rodrigo
rodrigo

Reputation: 98446

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.

Upvotes: 1

Related Questions