rhx/SwiftGtk

Fails to link to gtk/gdk/atk when building for gtk4 on Ubuntu 21.04

MasterBel2 opened this issue · 5 comments

error: link command failed with exit code 1 (use -v to see invocation)
/usr/bin/ld.gold: error: cannot find -lgtk-4.0
…
/usr/bin/ld.gold: error: cannot find -lgdk-4
…
/usr/bin/ld.gold: error: cannot find -latk-1.0

I don't have a tonne of experience here so I hope I'm missing something obvious. I had a look the system and couldn't find a library called GTK-4.0 anywhere that I could maybe add a path to, and ld seems to be looking in reasonable places for it. (I don't have that log, but I'm happy to get that for you if it would be useful.)

Swapped over to GTK3 and it worked first time.

rhx commented

Yes, SwiftGtk requires the relevant version of gtk (i.e. gtk3 or gtk4) to be installed, including the corresponding header files (e.g. libgtk-3-dev for Ubuntu). I don't think there is a libgtk-4-dev for Ubuntu 21.04 (sorry, I don't have 21.04 to test, but you could try sudo apt install libgtk-4-dev and see if that works). You might be able to compile and install gtk4 manually (just make sure that pkg-config can find the gtk4 libraries).

rhx commented

Looks like there is a libgtk-4-dev for Ubuntu 21.04, see: https://packages.ubuntu.com/source/hirsute/gtk4

For the setup, I ran sudo apt install libgtk-4-bin libgtk-4-common libgtk-4-dev libgtk-4-doc gir1.2-gtksource-4 gobject-introspection libgirepository1.0-dev libxml2-dev jq (as outlined in the readme). After the compile failed I double-checked that each of the dependencies had properly installed, and there didn't seem to be an issue.

I'll look into pkg-config, but I'm not familiar with the tool.

Unfortunately I spilled water on my pc keyboard yesterday, so having to type this from my macbook :( I'll get back to you when I have a working keyboard again

rhx commented

There was an error with the Gdk and Gtk module.modulemap files referencing the gtk4 libraries incorrectly. Can you check that this works for you now, when you do the following?

cd SwiftGtk
git checkout gtk4
git pull
swift package purge-cache
./distclean.sh
./run-gir2swift.sh
swift build
swift test

(the swift package purge-cache and ./distclean.sh commands are important to ensure the compiler doesn't pick up the old versions.)

Entirely forgot to run the purge-cache and ./distclean commands, but gtk4 build appears to be working!