#Running a gtk program outside the msys2 shell

1 messages · Page 1 of 1 (latest)

modern escarp
#

I would like to run a program written in C/GTK2 outside the msys shell.

Through ldd I checked the libraries needed at startup and put them in a folder outside msys2 together with the executable, I also added the contents of /lib/gdk-pixbuf-2.0/2.10.0/loaders.
From this position the program starts correctly but does not load the theme and icons.
this part of the program runs without returning any errors:

pixmap_dir = strdup("../img");
add_pixmap_directory (pixmap_dir);
Icon_path = g_strdup("../img/mini/");
g_free (pixmap_dir);

but the icons are not loaded.

I did these other tests which are valid for GTK3:

From MSYS2 I copied share/themes/Windows10/gtk-2.0 to the program folder

Also from MSYS2 I copied etc/gtk-2.0 into the program folder and inside it I created the settings.ini file with these lines:

[Settings]

gtk-theme-name=Windows10
gtk-font-name=Segoe UI 9

in the end I ran:

$ glib-compile-schemas /mingw64/share/glib-2.0/schemas/ --targetdir=/c/openhp/bin/

the program is loaded correctly if executed inside the shell and from the compilation directory, if through the shel I move to the external folder and run it from that position it fails to load neither the theme nor the icons.

I tried changing the PATH variable to g_setenv
g_setenv("PATH","./" ,TRUE);
but at the moment I can't find a solution
Does any of you have experience?

Thanks in advance for your attention
Paul

fast nest
#

I'm not sure how GTK3 works here (seeing the directory name gtk-2.0)...

#

My general suggestion is to find a piece of GTK-based software that has a Windows package (preferably mingw-based) and see what it does.

#

Below a list of what I think is more or less the files relating to GTK in gpg4win, slightly abridged.

./bin/freetype6.dll
./bin/gdbus.exe
./bin/gdk-pixbuf-pixdata.exe
./bin/gdk-pixbuf-query-loaders.exe
./bin/gio-querymodules.exe
./bin/glib-compile-resources.exe
./bin/glib-compile-schemas.exe
./bin/glib-genmarshal.exe
./bin/gobject-query.exe
./bin/gresource.exe
./bin/gsettings.exe
./bin/gspawn-win32-helper.exe
./bin/gspawn-win32-helper-console.exe
./bin/gtk-query-immodules-2.0.exe
./bin/gtk-update-icon-cache.exe
./bin/libatk-1.0-0.dll
./bin/libcairo-2.dll
./bin/libcairo-gobject-2.dll
./bin/libcairo-script-interpreter-2.dll
./bin/libexpat-1.dll
./bin/libffi-6.dll
./bin/libfontconfig-1.dll
./bin/libgailutil-18.dll
./bin/libgdk_pixbuf-2.0-0.dll
./bin/libgdk-win32-2.0-0.dll
./bin/libgio-2.0-0.dll
./bin/libglib-2.0-0.dll
./bin/libgmodule-2.0-0.dll
./bin/libgobject-2.0-0.dll
./bin/libgthread-2.0-0.dll
./bin/libgtk-win32-2.0-0.dll
./bin/libpango-1.0-0.dll
./bin/libpangocairo-1.0-0.dll
./bin/libpangoft2-1.0-0.dll
./bin/libpangowin32-1.0-0.dll
./bin/libpng14-14.dll
./bin/pango-querymodules.exe
./etc/fonts/fonts.conf
./etc/gtk-2.0/im-multipress.conf
./etc/pango/pango.modules
./lib/gtk-2.0/2.10.0/engines/libpixmap.dll
./lib/gtk-2.0/2.10.0/engines/libwimp.dll
./lib/gtk-2.0/2.10.0/immodules/...
./lib/gtk-2.0/modules/libgail.dll
./lib/libgpgme-glib.imp
./share/glib-2.0/schemas/gschema.dtd
./share/gpa/
./share/gpa/gpa.png
./share/gpa/gpa-logo.ppm
./share/locale/de/LC_MESSAGES/atk10.mo
./share/locale/de/LC_MESSAGES/glib20.mo
./share/locale/de/LC_MESSAGES/gtk20.mo
./share/locale/de/LC_MESSAGES/gtk20-properties.mo
./share/themes/Default/gtk-2.0-key/gtkrc
./share/themes/Emacs/gtk-2.0-key/gtkrc
./share/themes/MS-Windows/gtk-2.0/gtkrc
./share/themes/Raleigh/gtk-2.0/gtkrc
#

If you manage to successfully package your software, we'd be happy to link to a write-up explaining the challenges and solutions. (or just include it on the site)

modern escarp
#

I solved the problem this way:

#

Porting GTK2/GTK3 programs to windows using Msys2

• Download, install MSYS2
• update with pacman -Syuu

Install the gtk2/gtk3 development environment:

32-bit
pacman -S autoconf
pacman -S mingw-w64-i686-glib2
pacman -S glib2-devel
pacman -S automake
pacman -S mingw-w64-i686-gtk2
pacman -S mingw-w64-i686-glade-gtk2
pacman -S mingw-w64-i686-gtk3
pacman -S mingw-w64-clang-i686-libglade
pacman -S base-devel
pacman -S mingw-w64-i686-toolchain

64 bit
pacman -S mingw-w64-x86_64-glade
pacman -S mingw-w64-x86_64-glib2
pacman -S mingw-w64-x86_64-gtk2
pacman -S mingw-w64-x86_64-glade-gtk2
pacman -S mingw-w64-x86_64-gtk3
pacman -S mingw-64-clang-x86_64-libglade
pacman -S mingw-w64-x86_64-libglade
pacman -S mingw-w64-x68_64-toolchain

#

Creating the program tree outside the MSYS2 environment
mkdir /c/myfolder
mkdir /c/myfolder/bin
mkdir /c/myfolder/etc
mkdir /c/myfolder/img
mkdir /c/myfolder/lib
mkdir /c/myfolder/share
mkdir /c/myfolder/share/glib-2.0
mkdir /c/myfolder/share/themes

• Put the executable in the bin folder 
• run: ldd ./myprogram 
• transfer all required dlls to the bin folder except those belonging to windows.

To load the launcher theme:

GTK2
mkdir /c/myfolder/etc/gtk-2.0
create the gtkrc file by inserting this line
gtk-theme-name="Windows10"

GTK3
mkdir /c/myfolder/etc/gtk-3.0
create the settings.ini file by inserting these lines:
[Settings]
gtk-theme-name=Windows10
gtk-font-name=Segoe UI 9

Download the Windows 10 theme from Gnome-look and unpack it in the share/themes folder
Open msys2 shell and create schema in “/c/myfolder/share/glib-2.0”
glib-compile-schemas /mingw64/share/glib-2.0/schemas/ --targetdir=/c/myfolder/share/glib-2.0
Loading Icons:
cp -r /c/msys64/lib/gdk-pixbuf-2.0 /c/myfolder/lib

In the root folder of our program we have created the img folder but this depends on where in our program we have decided to look for the icons, in the case of GTK2 if we want to look for them in /c/myfolder/img, in our main.c we will write:

pixmap_dir = strdup("../img");
add_pixmap_directory (pixmap_dir);

proper sorrel
#

does ldd detects libEGL.dll and libGLESv2.dll as dependencies?

fast nest
modern escarp