Error while loading shared libraries: libgtk-4.so.1

I am facing a problem where I can not figure out how to fix it:
I am trying to develop GTK4 programs and everything works fine if I compile them from the command line , but I can not understand why I get this in Codeblocks:

error while loading shared libraries: libgtk-4.so.1

Here are some informations about the Enviroment:

Here are some informations about the Codeblocks setup I have:

After I compile the program with codeblocks and everything is fine, when I click on run i get this:

/home/michi/Templates/GTK4/bin/Debug/GTK4: error while loading shared libraries: libgtk-4.so.1: cannot open shared object file: No such file or directory

I had to fill those serach directories with that information because just putting pkg-config --cflags gtk4 and pkg-config --libs gtk4 does not work at all.

One last thing, if I use comand line works fine with:

gcc `pkg-config --cflags gtk4` program.c -o program `pkg-config --libs gtk4`

This is what Build log from Codeblocks outputs:

-------------- Build: Debug in GTK4 (compiler: GNU GCC Compiler)---------------

gcc -Wall -g -I/home/michi/usr/include/gtk-4.0 -I/home/michi/usr/include/glib-2.0 -I/home/michi/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/cairo -I/home/michi/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/home/michi/usr/include/gdk-pixbuf-2.0 -I/home/michi/usr/include/graphene-1.0 -I/home/michi/usr/lib/x86_64-linux-gnu/graphene-1.0/include -c /home/michi/Templates/GTK4/main.c -o obj/Debug/main.o
gcc -L/home/michi/usr/lib -L/home/michi/usr/lib/x86_64-linux-gnu -L/home/michi/usr/lib/x86_64-linux-gnu/pkgconfig -o bin/Debug/GTK4 obj/Debug/main.o /home/michi/usr/lib/x86_64-linux-gnu/libgtk-4.so /home/michi/usr/lib/x86_64-linux-gnu/libgtk-4.so.1 /home/michi/usr/lib/x86_64-linux-gnu/libglib-2.0.so /home/michi/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so /home/michi/usr/lib/x86_64-linux-gnu/libpango-1.0.so /home/michi/usr/lib/x86_64-linux-gnu/libgio-2.0.so /home/michi/usr/lib/x86_64-linux-gnu/libgobject-2.0.so
Output file is bin/Debug/GTK4 with size 19.88 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

-------------- Run: Debug in GTK4 (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/michi/Templates/GTK4/bin/Debug/GTK4
Set variable: LD_LIBRARY_PATH=.:
Executing: gnome-terminal -t GTK4 -x /usr/bin/cb_console_runner LD_LIBRARY_PATH=:. /home/michi/Templates/GTK4/bin/Debug/GTK4 (in /home/michi/Templates/GTK4/.)
Process terminated with status 0 (0 minute(s), 0 second(s))

1 Like

Strange but after I added this:

CPPFLAGS="-I$HOME/usr/include"
LDFLAGS="-L$HOME/usr/lib"
PKG_CONFIG_PATH="$HOME/usr/lib/pkgconfig:$HOME/usr/lib/x86_64-linux-gnu/pkgconfig:$HOME/usr/share/pkgconfig"
export CPPFLAGS LDFLAGS PKG_CONFIG_PATH

LD_LIBRARY_PATH="$HOME/usr/lib/x86_64-linux-gnu/"
PATH="$HOME/usr/bin:$PATH"
export LD_LIBRARY_PATH PATH

XDG_DATA_DIRS=$HOME/usr/share:$XDG_DATA_DIRS
export XDG_DATA_DIRS
export GSETTINGS_SCHEMA_DIR=$HOME/usr/share/glib-2.0/schemas
export GI_TYPELIB_PATH=$HOME/usr/lib/x86_64-linux-gnu/girepository-1.0

to $HOME/..bashrc works.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.