Gtk not found on linux

I’m trying to test out the webviews in the new JUCE branch on linux mint, but I’m running into trouble with the compilation stage in cmake not finding my gtk installation. This only happens when I set the flag JUCE_WEB_BROWSER=1, which I believe is required for me to start using the WebComponents (according to the tutorial I’m following).

I’ve installed both the latest versions of gtk (gtk-4) as well as the earlier version gtk-3, and they’re both present in my /usr/include folder. Despite this, these gtk installations still can’t be found.

Is there a way in cmake to link the gtk headers within the build process, or is there a more obvious solution to this?

you need to install webkit2gtk devel package JUCE/docs/Linux Dependencies.md at develop · juce-framework/JUCE · GitHub

1 Like

Gtk should just simply install with apt. If you can’t find the right package, maybe try the libgtk-3-dev one (I’m not sure if it will work, but it seems like it).

If you have problems with libwebkit2gtk-4.0, check this issue out. The workaround from the “Workaround” section worked for me.

As per the document linked above, the current recommendation is to install libwebkit2gtk-4.1, but libwebkit2gtk-4.0 will work too, in case the distro is only providing that.

libwebkit2gtk-4.1 didn’t work for me on the newest Ubuntu. Linux Mint is Ubuntu-based so there is quite a big chance that the poster will need to install libwebkit2gtk-4.0 instead of 4.1.

This indeed used to be an issue recently, and was hopefully fixed by this commit

If you’re still encountering such issues with the current develop branch, we will look into it.

Don’t forget, Debian users, that if you get into problems with compile sessions not finding headers that are expected, you can use the ‘apt-file’ program to find out which specific package on your system provides that file, e.g.:

$ apt-file search gtk.h

… this will show you which packages have the ‘gtk.h’ header included in your system.

Many a frustrating compile has been avoided by using apt-file (which must be ‘apt-file update’-ed after install, don’t forget) to find the right package containing the needed header …

2 Likes

Ok. As I suspected, it was a lot more obvious than I thought.

In the juce_add_plugin directive, you need to write the flag NEEDS_WEB_BROWSER to TRUE in order for juce to actually link with the webkit.

This was found directly in the CMake api at JUCE/docs/CMake API.md at master · juce-framework/JUCE · GitHub under the juce_add_<target> Functions header

Thanks everyone for the responses!

Edit: This is for linux specifically. I believe for Windows you need to write the NEEDS_WEBVIEW2 to TRUE

Hmm I tried to build a project I and added this to every juce_add_<...> call I could find, but it still can’t find the GTK header … is there another way around it?

(on Arch Linux with webkit2gtk-4.1)

EDIT:

found this workaround:

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(WEBKIT2GTK REQUIRED webkit2gtk-4.1)

include_directories(${GTK3_INCLUDE_DIRS} ${WEBKIT2GTK_INCLUDE_DIRS})