ToshioCP / Gtk4-tutorial

GTK 4 tutorial for beginners
https://toshiocp.github.io/Gtk4-tutorial/
550 stars 49 forks source link

Issue in the Glib Installation Section #5

Closed lilithi closed 3 years ago

lilithi commented 3 years ago

I am working through your tutorial, and it's been a big help with getting started. I did encounter an issue at the very beginning, and including a note about how to resolve this may help other beginners who encounter this issue. In the Glib Installation section, when I ran meson --prefix $HOME/local _build I got the error meson.build:1:0: ERROR: Compiler cc can not compile programs. I was able to resolve it with sudo apt install gcc-multilib The solution was not obvious from the meson-log.txt

In case its relevant, I'm on Linux Mint 20, which is based on Ubuntu 20.04.

Edit: For anyone looking for a solution to this problem in the future, I would guess apt-get install libc-dev is what is most likely to fix your issues

dvergeylen commented 3 years ago

I also experienced a problem with Glib when compiling it next to Gtk4.

Although setting the env variables to appropriate values:

export LD_LIBRARY_PATH="/path/to/glib-2.67.2/lib/x86_64-linux-gnu/:/path/to/gtk4-lib/lib/x86_64-linux-gnu/"

my programs crashed when using a FileChooser:

GLib-GIO-ERROR **: 21:51:27.033: Settings schema 'org.gtk.gtk4.Settings.FileChooser' is not installed

The problem is that Glib doesn't know the appropriate schemas for FileChooser, which are in the (freshly compiled) gtk4 directory (share/glib-2.0/schemas). You can compile them via glib-compile-schemas share/glib-2.0/schemas/ (from the gtk4 installation directory). This will produce a gschemas.compiled.

You then set GSETTINGS_SCHEMA_DIR accordingly:

export GSETTINGS_SCHEMA_DIR=/path/to/gtk4-lib/share/glib-2.0/schemas

Source

ToshioCP commented 3 years ago

Dear Lilithi

Thank you for the information. I use UBUNTU 20.10 and I've built gtk4 on it. I checked the package gcc-multilib. Then I found the package is NOT installed in my computer. So, It might not the direct cause of your problem, But I don't have enough knowledge to make things clear.

lilithi commented 3 years ago

The meson-logs.txt outputs

Sanity check compile stderr:
/usr/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status

meson.build:1:0: ERROR: Compiler cc can not compile programs.

Searches about this lead to a Stack Exchange question from 2011. The problem must be common as replies are from as late as 2017. It contains a ton of answers, but my guess is this solution most likely to be helpful:

Seems that while you were playing with llvm/clang you(or the package manager) removed previously existing standard C library development package (eglibc on Debian) or maybe you didn't have it installed in the first place, thus you need to reinstall it, now that you reverted back to gcc.

You can do so like this on Debian:

aptitude show libc-dev

Ubuntu:

apt-get install libc-dev

That said, the answers are all over the place, and unfortunately, I don't know enough to be certain this would be helpful.

ToshioCP commented 3 years ago

Maybe the message in Stack Exchange is the answer, In my computer, libc6-dev (libc-dev is a meta package that points libc6-dev) is installed. It is an indispensable package for gcc.

ToshioCP commented 3 years ago

This issue was posted in January 2021. At that time, installation was only possible by building from the source. Now (May/2021) it is possible to install it from the distribution packages (Arch, Debian, Ubuntu and Fedora). Therefore, this issue isn't so serious now.