How to install GTK 3 headers?

#1

I have a working (on macOS, Debian and Ubuntu) CMakeList.txt which contains the following:

pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})

I get this:

stanislas@nixpsla ~/p/f/build> (master|✔) cmake ..
-- Checking for module 'gtk+-3.0'
--   No package 'gtk+-3.0' found
CMake Error at /nix/store/lkpvvfj7r1838c7aifcpvj9scpgi3j61-cmake-3.13.4/share/cmake-3.13/Modules/FindPkgConfig.cmake:452 (message):
  A required package was not found
Call Stack (most recent call first):
  /nix/store/lkpvvfj7r1838c7aifcpvj9scpgi3j61-cmake-3.13.4/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal)
  CMakeLists.txt:15 (pkg_check_modules)

I installed the gtk3 derivation. What am I missing?

#2

You will also need to add pkgconfig and make sure you are following https://nixos.wiki/wiki/FAQ#I_installed_a_library_but_my_compiler_is_not_finding_it._Why.3F

2 Likes
#3

Headers and libraries are not in a system-wide search path. You can enter an environment with the headers visible using nix-shell, e.g.:

nix-shell -p gtk3 pkgconfig

You can also make a default.nix, specifying the build dependencies:

with import <nixpkgs> {};
stdenv.mkDerivation {
  name = "env";
  buildInputs = [
    gtk3 pkgconfig
  ];
}

Then you can run nix-shell in the directory where default.nix resides.

1 Like