Cross-compiling GTK+, missing icons

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cross-compiling GTK+, missing icons

Gerardo Ballabio-2
It looks like no moderators are actually _reading_ this list...
Resending without attachments.

2017-05-23 22:54 GMT+02:00 Gerardo Ballabio <[hidden email]>:
Hello all,

I'm trying to cross-compile GTK+ for Windows on Linux (Debian) using MXE (http:/mxe.cc/). My goal is to produce a statically linked executable that just runs without having to install anything else (libraries, themes, etc.). I saw that in a previous thread someone said that GTK+ can't be statically linked, but that isn't true, it actually works fine (at least on Windows).

There is only one thing that doesn't work: the icons that are part of the standard interface (for example, the "+" and "-" that appear on the buttons of a GtkSpinButton) aren't displayed. When I run it, the program prints a warning saying that it can't find the "hicolor" theme, and all icons are replaced by a "missing icon" symbol.

I suppose that if I installed the theme on the target system, it would work (although I'm not sure in which directories GTK+ looks for it). But as I wrote above, I want the icons to be embedded in the executable, so that one can just download the file and run it. That is definitely possible with GTK+ 2, I compiled several programs and they all work without issues. But I haven't been able to make it work with GTK+ 3, so I'm asking for your help.

The problem is demonstrated by the attached screenshots:
- a window containing a GtkSpinButton (spinbutton-gtk3.png)
- a window containing a GtkToolbar with two buttons (toolbar-gtk3.png)
- the latter program rewritten for GTK+ 2 (toolbar-gtk2.png). As you can see, here the icons are displayed correctly.
I'm also attaching the source code of those examples.

I've tried to dig into the GTK+ sources to find where the icons are generated, but got lost. I found that there's a program called gtk-update-icon-cache that I guess might have to do with that, but I didn't understand how it's supposed to be used and where it's called during the build process (if it's called at all).

To reproduce what I did, go to http:/mxe.cc/ and follow the instructions. The GTK+ 3 library is configured with the following options (specified in the src/gtk3.mk file in the MXE source tree):

--disable-glibtest --disable-cups --disable-test-print-backend --disable-gtk-doc --disable-man --with-included-immodules --enable-win32-backend

MXE also applies a few patches to the GTK+ sources (file src/gtk3-1-fixes.patch).

Thank you in advance for any help that you can provide.

Gerardo




_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Vilem Otte
I'm not the moderator, just a user who works with Gtk+ for quite some time... I've never tried to actually cross compile for Windows, while I did a full compilation on both - Linux and Windows (as I require certain OpenGL widgets support, which was quite poor for quite long time ... it got a lot better in past years).

Icons, among other resources, are missing from the source itself and have to be "shipped" outside of the libraries in 'share\icons\STYLE', next to executable. I believe this is mandatory as of now. I had to obtain the style separately and add it to appropriate locations.

I'm not even sure you can include whole style for Gtk+ 3.x inside the library (although I might be wrong here!).

On Sun, May 28, 2017 at 6:09 PM, Gerardo Ballabio <[hidden email]> wrote:
It looks like no moderators are actually _reading_ this list...
Resending without attachments.

2017-05-23 22:54 GMT+02:00 Gerardo Ballabio <[hidden email]>:
Hello all,

I'm trying to cross-compile GTK+ for Windows on Linux (Debian) using MXE (http:/mxe.cc/). My goal is to produce a statically linked executable that just runs without having to install anything else (libraries, themes, etc.). I saw that in a previous thread someone said that GTK+ can't be statically linked, but that isn't true, it actually works fine (at least on Windows).

There is only one thing that doesn't work: the icons that are part of the standard interface (for example, the "+" and "-" that appear on the buttons of a GtkSpinButton) aren't displayed. When I run it, the program prints a warning saying that it can't find the "hicolor" theme, and all icons are replaced by a "missing icon" symbol.

I suppose that if I installed the theme on the target system, it would work (although I'm not sure in which directories GTK+ looks for it). But as I wrote above, I want the icons to be embedded in the executable, so that one can just download the file and run it. That is definitely possible with GTK+ 2, I compiled several programs and they all work without issues. But I haven't been able to make it work with GTK+ 3, so I'm asking for your help.

The problem is demonstrated by the attached screenshots:
- a window containing a GtkSpinButton (spinbutton-gtk3.png)
- a window containing a GtkToolbar with two buttons (toolbar-gtk3.png)
- the latter program rewritten for GTK+ 2 (toolbar-gtk2.png). As you can see, here the icons are displayed correctly.
I'm also attaching the source code of those examples.

I've tried to dig into the GTK+ sources to find where the icons are generated, but got lost. I found that there's a program called gtk-update-icon-cache that I guess might have to do with that, but I didn't understand how it's supposed to be used and where it's called during the build process (if it's called at all).

To reproduce what I did, go to http:/mxe.cc/ and follow the instructions. The GTK+ 3 library is configured with the following options (specified in the src/gtk3.mk file in the MXE source tree):

--disable-glibtest --disable-cups --disable-test-print-backend --disable-gtk-doc --disable-man --with-included-immodules --enable-win32-backend

MXE also applies a few patches to the GTK+ sources (file src/gtk3-1-fixes.patch).

Thank you in advance for any help that you can provide.

Gerardo




_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Nicola Fontana-3
Il Sun, 28 May 2017 18:27:46 +0200 Vilem Otte <[hidden email]> scrisse:

> ...
> I'm not even sure you can include whole style for Gtk+ 3.x inside the
> library (although I might be wrong here!).
> ...

Hi Vilem,

if with "style" you mean the GTK+ theme then yes, you need to
include it separately.

I'm used to cross-compile for Windows on Linux and lately (since
3.14.0 IIRC) the adwaita theme became a new external dependency in
the toolchain I use.

Ciao.
--
Nicola
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Ian Chapman
In reply to this post by Gerardo Ballabio-2
Hi, maybe your previous thread was one that I initiated.  The reply was nogo or use a docker.  I'm wondering if you managed to generate a Win.exe that ran without loading any extras on all versions of windows?  I'm sure what I was doing would work only with the exact compile version even on the same distro version.  Regards Ian.

On 28/05/17 12:09 PM, Gerardo Ballabio wrote:
It looks like no moderators are actually _reading_ this list...
Resending without attachments.

2017-05-23 22:54 GMT+02:00 Gerardo Ballabio <[hidden email]>:
Hello all,

I'm trying to cross-compile GTK+ for Windows on Linux (Debian) using MXE (http:/mxe.cc/). My goal is to produce a statically linked executable that just runs without having to install anything else (libraries, themes, etc.). I saw that in a previous thread someone said that GTK+ can't be statically linked, but that isn't true, it actually works fine (at least on Windows).

There is only one thing that doesn't work: the icons that are part of the standard interface (for example, the "+" and "-" that appear on the buttons of a GtkSpinButton) aren't displayed. When I run it, the program prints a warning saying that it can't find the "hicolor" theme, and all icons are replaced by a "missing icon" symbol.

I suppose that if I installed the theme on the target system, it would work (although I'm not sure in which directories GTK+ looks for it). But as I wrote above, I want the icons to be embedded in the executable, so that one can just download the file and run it. That is definitely possible with GTK+ 2, I compiled several programs and they all work without issues. But I haven't been able to make it work with GTK+ 3, so I'm asking for your help.

The problem is demonstrated by the attached screenshots:
- a window containing a GtkSpinButton (spinbutton-gtk3.png)
- a window containing a GtkToolbar with two buttons (toolbar-gtk3.png)
- the latter program rewritten for GTK+ 2 (toolbar-gtk2.png). As you can see, here the icons are displayed correctly.
I'm also attaching the source code of those examples.

I've tried to dig into the GTK+ sources to find where the icons are generated, but got lost. I found that there's a program called gtk-update-icon-cache that I guess might have to do with that, but I didn't understand how it's supposed to be used and where it's called during the build process (if it's called at all).

To reproduce what I did, go to http:/mxe.cc/ and follow the instructions. The GTK+ 3 library is configured with the following options (specified in the src/gtk3.mk file in the MXE source tree):

--disable-glibtest --disable-cups --disable-test-print-backend --disable-gtk-doc --disable-man --with-included-immodules --enable-win32-backend

MXE also applies a few patches to the GTK+ sources (file src/gtk3-1-fixes.patch).

Thank you in advance for any help that you can provide.

Gerardo





_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Carsten Mattner
In reply to this post by Vilem Otte
On Sun, May 28, 2017 at 4:27 PM, Vilem Otte <[hidden email]> wrote:

> I'm not the moderator, just a user who works with Gtk+ for quite
> some time... I've never tried to actually cross compile for Windows,
> while I did a full compilation on both - Linux and Windows (as I
> require certain OpenGL widgets support, which was quite poor for
> quite long time ... it got a lot better in past years).
>
> Icons, among other resources, are missing from the source itself and
> have to be "shipped" outside of the libraries in
> 'share\icons\STYLE', next to executable. I believe this is mandatory
> as of now. I had to obtain the style separately and add it to
> appropriate locations.

Windows PE executables have a nice feature where there's a resource
section which is by convention used for strings and also graphics like
the program's icons. This is common and natural on Windows, so if you
can load the file dynamically at runtime and set icons explicitly,
then provided your cross compiler is able to include the needed PE
section, you can build a self-contained file which is one .exe with
all the needed code and data/resources. This feature of PE files
is as old as Windows itself and will work, if that's a concern of
yours, if you can generate the desired .exe and can convince
GTK+ to load stuff at runtime manually.

> I'm not even sure you can include whole style for Gtk+ 3.x inside
> the library (although I might be wrong here!).
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Gerardo Ballabio-2
In reply to this post by Gerardo Ballabio-2
Thanks for your answers.

2017-05-28 22:05 GMT+02:00 Ian Chapman <[hidden email]>:
Hi, maybe your previous thread was one that I initiated.  The reply was nogo or use a docker.  I'm wondering if you managed to generate a Win.exe that ran without loading any extras on all versions of windows?  I'm sure what I was doing would work only with the exact compile version even on the same distro version.

Yes, I managed to build self-contained Windows executables (using GTK+ 2) that don't need any additional resources to be installed. Just download the file and run it. I tested with Windows XP and 7, but I expect them to work on newer Windows versions too. For example see here: http://www.nongnu.org/galois/#download

2017-05-28 18:27 GMT+02:00 Vilem Otte <[hidden email]>:
Icons, among other resources, are missing from the source itself and have to be "shipped" outside of the libraries in 'share\icons\STYLE', next to executable. I believe this is mandatory as of now.

Uhm. I'm sure there were good reasons, but this looks like a regression to me. Given that some icons are a required part of standard widgets (for example GtkSpinButton won't display properly without them), I'd expect that a fallback be always available.

2017-05-28 22:35 GMT+02:00 Carsten Mattner <[hidden email]>:
Windows PE executables have a nice feature where there's a resource
section which is by convention used for strings and also graphics like
the program's icons. This is common and natural on Windows, so if you
can load the file dynamically at runtime and set icons explicitly,
then provided your cross compiler is able to include the needed PE
section, you can build a self-contained file which is one .exe with
all the needed code and data/resources. This feature of PE files
is as old as Windows itself and will work, if that's a concern of
yours, if you can generate the desired .exe and can convince
GTK+ to load stuff at runtime manually.

I'll ask whether that is supported.

2017-05-29 10:48 GMT+02:00 Rafal Luzynski <[hidden email]>:
This looks like a good solution to me. But instead of placing the icons
in external files you (I'm talking to John) may be also interested in
GResource framework [1] which does a similar thing like Windows resources,
that means embeds images and other data files inside the executable file
but is not based on Windows API.

It looks like that would suit my needs too.

Thank you all again.
Gerardo


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Gerardo Ballabio-2
In reply to this post by Nicola Fontana-3
Whoops, sorry, missed this one:

2017-05-28 21:20 GMT+02:00 Nicola Fontana <[hidden email]>:
if with "style" you mean the GTK+ theme then yes, you need to
include it separately.

I'm used to cross-compile for Windows on Linux and lately (since
3.14.0 IIRC) the adwaita theme became a new external dependency in
the toolchain I use.

Which toolchain are you using please? Do you generate self-contained binaries or do you need to install extra stuff?

Thanks
Gerardo


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Nicola Fontana-3
Il Mon, 29 May 2017 12:09:49 +0200 Gerardo Ballabio <[hidden email]> scrisse:

> > if with "style" you mean the GTK+ theme then yes, you need to
> > include it separately.
> >
> > I'm used to cross-compile for Windows on Linux and lately (since
> > 3.14.0 IIRC) the adwaita theme became a new external dependency in
> > the toolchain I use.
> >  
>
> Which toolchain are you using please?

I'm using my aur-fedora-mingw toolchain for Archlinux [1] that in
turn is based on the Fedora one [2].

> Do you generate self-contained
> binaries or do you need to install extra stuff?

I build a single installer with NSiS [3]. This will unzip all the
needed stuff under "C:\Program files\Whatever": see my script [4]
as an example.

It seems to be a lot of work (and it is!) but now I can build the
installer (for win32 or win64) by simply issuing a make command in
the appropriate build tree. My only problem is I cannot check the
result because I don't own a windows box ;)

[1] https://github.com/ntd/aur-fedora-mingw
[2] https://fedoraproject.org/wiki/MinGW/CrossCompilerFramework
[3] http://nsis.sourceforge.net/Main_Page
[4] https://github.com/ntd/adg/blob/master/build/adg.nsi

Ciao.
--
Nicola
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Carsten Mattner
In reply to this post by Gerardo Ballabio-2
On Mon, May 29, 2017 at 9:24 AM, Gerardo Ballabio
<[hidden email]> wrote:

> 2017-05-29 10:48 GMT+02:00 Rafal Luzynski <[hidden email]>:
> >
> > This looks like a good solution to me. But instead of placing the icons
> > in external files you (I'm talking to John) may be also interested in
> > GResource framework [1] which does a similar thing like Windows resources,
> > that means embeds images and other data files inside the executable file
> > but is not based on Windows API.
>
>
> It looks like that would suit my needs too.

I didn't know about GResource. It looks exactly like what you want and
AFAIU achieves cross platform support by generating .h and .c files
by serializing the resources. No special platform dependency like
PE sections.

https://developer.gnome.org/gio/stable/GResource.html

You should try this first and please report back. I'm curious.
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Michael Torrie
In reply to this post by Gerardo Ballabio-2
On 05/29/2017 03:24 AM, Gerardo Ballabio wrote:
> Yes, I managed to build self-contained Windows executables (using GTK+
> 2) that don't need any additional resources to be installed. Just download
> the file and run it. I tested with Windows XP and 7, but I expect them
> to work on newer Windows versions too. For example see here:
> http://www.nongnu.org/galois/#download

Very interesting. How did you do this?  So far as I know GTK isn't even
designed to work in a statically-linked scenario.
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Gerardo Ballabio-2
I simply downloaded and built the MXE cross-compiling suite. GTK+ (and gtkmm) are among supported libraries. See here: http://mxe.cc/

Gerardo


2017-05-30 2:00 GMT+02:00 Michael Torrie <[hidden email]>:
On 05/29/2017 03:24 AM, Gerardo Ballabio wrote:
> Yes, I managed to build self-contained Windows executables (using GTK+
> 2) that don't need any additional resources to be installed. Just download
> the file and run it. I tested with Windows XP and 7, but I expect them
> to work on newer Windows versions too. For example see here:
> http://www.nongnu.org/galois/#download

Very interesting. How did you do this?  So far as I know GTK isn't even
designed to work in a statically-linked scenario.
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross-compiling GTK+, missing icons

Gerardo Ballabio-2
In reply to this post by Nicola Fontana-3
I found indeed that downgrading the version of GTK+ to 3.12, the icons came back.
But I'll explore the GResource route too, as I'm going to need a newer version (at least 3.16 for OpenGL support).

Gerardo


2017-05-28 21:20 GMT+02:00 Nicola Fontana <[hidden email]>:
Il Sun, 28 May 2017 18:27:46 +0200 Vilem Otte <[hidden email]> scrisse:

> ...
> I'm not even sure you can include whole style for Gtk+ 3.x inside the
> library (although I might be wrong here!).
> ...

Hi Vilem,

if with "style" you mean the GTK+ theme then yes, you need to
include it separately.

I'm used to cross-compile for Windows on Linux and lately (since
3.14.0 IIRC) the adwaita theme became a new external dependency in
the toolchain I use.

Ciao.
--
Nicola


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Loading...