0

I am using MingW32 and am trying to install the package mingw-w64-x86_64-gtk3, however, that's not available via the apt install and it looks like you could only install it via pacman. Could someone show me the way to make it work (possibly without using MSYS2, as I pretty much got everything working except I'm missing the GTK3 part).

Namely, I need this package but it looks like you could only get it off MSYS2 using pacman: https://packages.msys2.org/package/mingw-w64-x86_64-gtk3

Environment/Setup:

  • Windows 11
  • Ubuntu 22.04 (WSL2)
    • apt install mingw-w64

I am able to compile all my CLI executables inside the Ubuntu 22.04 with MingW32 and running it fine in Windows.. I also have 2 small GUI applications that I want to get them to work too and they uses GTK3. I am able to compile them too but only in Windows using MSYS2, but I really want to just compile/build everything off Ubuntu environment to keep everything simple.

New contributor
codenamezero is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
11
  • packages.ubuntu.com/jammy/mingw-w64 is found in Ubuntu repositories, why not use it?
    – guiverc
    Jan 25 at 3:43
  • Because there is no gtk3? I am already using mingw-w64-x86-64 Jan 25 at 4:05
  • Are you on Windows (+WSL) or on actual Linux? Where did you get your existing mingw32? Jan 25 at 4:26
  • I am on Windows running Ubuntu 22.04 (WSL2), I've updated my original post to describe my setup. I was going to try to install pacman in Ubuntu and then just maybe try to install mingw-w64-x86_64-gtk3 but I read that it is not recommended to use pacman. Jan 25 at 4:47
  • Please use @username when replying, otherwise I don't get notifications. Jan 25 at 7:55

1 Answer 1

1

I've made Quasi-MSYS2, which helps download MSYS2 packages on Linux.

sudo apt install make wget tar zstd gpg

git clone https://github.com/HolyBlackCat/quasi-msys2
cd quasi-msys2/
make install _gtk4   # equivalent to `make install mingw-w64-x86_64-gtk4`

This downloads GTK4 to the current directory (./root/mingw64/) for you to use.

But there's a problem: MinGW comes in different flavors, and the flavors provided by MSYS2 may or may not be compatible with the flavor provided by Ubuntu.

The recommended build method doesn't depend on external MinGW. Instead I suggest using Clang, which can work with any MinGW flavor, if provided the right libraries (which we download from MSYS2).

sudo apt install wine   # Optional.

# Install latest Clang
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh
rm llvm.sh

# Install more packages
make install _gcc _gdb    # We won't be using GCC, but we need libraries that come with it.

# Opens a new shell with the right environment variables configured.
env/shell.sh

Then, testing on Hello World from here:

# Notice `pkg-config` picking up the correct libraries.
win-clang++ hello_world.cpp `pkg-config --cflags --libs gtk4`
# This opens the app in Wine:
./a.exe

Your Answer

codenamezero is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.