Hello all, I’m able to compile a “hello world” style application using a Makefile in Linux and Windows (using MSYS2), however, the resulting file is about 300k and doesn’t run on its own (complains that it is missing dlls for gio, gobject, gdk, gtk).
Actually I am still figuring out how to make my Makefile work on windows, as there is one command i have to run manually, relating to -export-dynamic which needs to be -Wl,--export-all-symbols on Windows.
I know that I can distribute these dlls with my application but I was hoping to (since I am “going to the trouble” of coding in C) package as a standalone executable. Thanks for any information on this.
Actually, I was thinking that I would be able to figure out how to get those dll’s from this post but I don’t know how to actually do it based on the information there.
And actually, I haven’t written too much code so I don’t mind switching over to gtk 4 or anything - just how can i get the app to run on my end user’s machine without installing the whole compilation tool chain?
Please, don’t use a plain Makefile for building your code. You’re just going to hurt yourself, and make your life miserable.
We typically recommend using build systems like Meson, which take care of a lot of things for you instead of having to re-invent the past 35 years of software development history.
If you want to distribute your application on Linux yourself, the recommended tool is Flatpak.
If you want to distribute your application on Windows, you will need to use an installer, like NSIS and include all the build artifacts, including the dependencies of your GTK application—DLLs, icons, binaries.
I was looking at Meson based on gtk4 posts, I was just trying to explore my gtk3 options first.
Re Flatpak: I figure if you’re distributing on linux, just have your all load .so from the usual places and tell your user to apt-get/yum install a couple of things, since they’re a linux user anyways.
Re: NSIS: I am really avoiding needing an “Installer” proper. This would actually be a sort of bootstrapping program, so I was asked to make this one simple. Really, I just want to be like the go ecosystem where everything is just shipped as binaries. curl it, chmod +x (check the checksums) and you’re off to the races. So I would probably need to study Meson quite a bit before I get to that result. That’s really what I’m after.
Btw, the dll-based solution for those using msys2: is to go to the /mingw64/bin in the fake filesystem that the msys2 shell sets up (the real windows filesystem path is relative to the folder you installed msys insto, for me that was C:\msys64 so the absolute path is C:\msys64\mingw64\bin). I just got all the dlls and my app was able to start up.
The command is tar cvzf libs.tgz $(find . -name '*.dll'). Run it in /mingw64/bin.
Is it really not possible to ship a big exe? Or what would be known as the “uber jar” in the Java world?
Meson doesn’t really care about the version of GTK: you can use is for GTK3 or GTK4 projects.
That’s… really not how it works. You need to care about the version of the dependencies, and the fact that you don’t really just have a binary. Applications are made of an executable, desktop files, settings schemas, icons, and other ancillary files. Without those, your application is literally a “hello world” (and a poorly integrated one at that).
Additionally, while you may have a dependency on version x.y.z of a library, that version is not necessarily available in the user’s system—or if it is, it might require a whole lot of upgrades.
Flatpak allows you to depend on well-known dependencies, shipped in run times, and stable across distributions; and if you depend on specific libraries, you can bundle those in your project without necessarily statically linking everything.
That’s never going to work. Windows is not Linux, you cannot really assume that all the dependencies are going to be installed system wide. You must ship your dependencies with your application.
The way that Go works is that it ships everything statically linked together and it doesn’t have any ancillary files. You may have noticed that Go applications are really all self-contained CLI tools. That’s not GUI applications work, and that’s definitely not how GTK applications work.
I’m sorry, but that’s horrific. It’s a security disaster waiting to happen, and it’s not going to work anywhere.