Skip to content

Instantly share code, notes, and snippets.

@mjakeman
Last active February 11, 2025 01:47
Show Gist options
  • Save mjakeman/0add69647a048a5e262d591072c7facb to your computer and use it in GitHub Desktop.
Save mjakeman/0add69647a048a5e262d591072c7facb to your computer and use it in GitHub Desktop.

Revisions

  1. mjakeman revised this gist Jun 8, 2021. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions distribute-windows-msys2.md
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,14 @@ GTK will display a fallback 'missing icon' symbol.

    ```sh
    $ cp -r /mingw64/share/icons/* ./share/icons/
    ```

    ## 4. Schemas
    The relevant settings schemas need to be installed. Copy them over and recompile. You
    may want to manually inspect the copied over schemas (in case unrelated projects are
    also copied).

    ```sh
    $ cp /mingw64/share/glib-2.0/schemas/* share/glib-2.0/schemas/
    $ glib-compile-schemas.exe share/glib-2.0/schemas/
    ```
  2. mjakeman revised this gist Apr 6, 2021. 1 changed file with 26 additions and 3 deletions.
    29 changes: 26 additions & 3 deletions distribute-windows-msys2.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,35 @@
    # Distribute GTK Apps with Windows (MSYS2)
    Under msys2, running the following command copies all dependent DLLs to the current directory:
    Make sure package `mingw-w64-x86_64-gtk3` is installed. Build your project
    with a custom prefix (e.g. `~/my-gtk-app-prefix`). Navigate to this directory
    such that you have subdirectories 'bin', 'lib', 'share', etc containing
    the executable to distribute.

    ## 1. Dependent DLLs
    The following command copies all dependent DLLs to the current directory:

    ```sh
    $ ldd mygtkapp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" .
    $ ldd bin/mygtkapp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" ./bin
    ```

    Where `mygtkapp.exe` is the executable in question (e.g. `gtk3-demo`, etc). This
    ensures that the necessary DLLs are bundled in the application folder so the end
    user does not need their own installation of msys2.

    All credit to: [https://stackoverflow.com/a/50130668](https://stackoverflow.com/a/50130668)
    All credit to: [https://stackoverflow.com/a/50130668](https://stackoverflow.com/a/50130668)

    ## 2. GdkPixbuf Loaders
    GTK will crash if it cannot load images. GdkPixbuf needs various loaders
    for different image formats. Your prebuilt loaders will suffice.

    Copy them over to the custom prefix directory:
    ```sh
    cp -r /mingw64/lib/gdk-pixbuf-2.0 ./lib/gdk-pixbuf-2.0
    ```

    ## 3. Icon Theme
    We then need to copy over the Adwaita and hicolor icon themes, otherwise
    GTK will display a fallback 'missing icon' symbol.

    ```sh
    $ cp -r /mingw64/share/icons/* ./share/icons/
    ```
  3. mjakeman created this gist Apr 6, 2021.
    12 changes: 12 additions & 0 deletions distribute-windows-msys2.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # Distribute GTK Apps with Windows (MSYS2)
    Under msys2, running the following command copies all dependent DLLs to the current directory:

    ```sh
    $ ldd mygtkapp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" .
    ```

    Where `mygtkapp.exe` is the executable in question (e.g. `gtk3-demo`, etc). This
    ensures that the necessary DLLs are bundled in the application folder so the end
    user does not need their own installation of msys2.

    All credit to: [https://stackoverflow.com/a/50130668](https://stackoverflow.com/a/50130668)