How to add libzip as dependency in meson build system

342 Views Asked by At

I'm building a small app using gtk+-3.0 in Gnome Builder, but I want to use libzip for some functions. But apparently meson is not accepting to add libzip. See my snippet:

foo_deps = [
  dependency('libzip', version: '>= 1.5.0'),
  dependency('gio-2.0', version: '>= 2.50'),
  dependency('gtk+-3.0', version: '>= 3.22')
]

This is my error message:

../../../../../../Projetos/foo/src/meson.build:8:0: ERROR: Dependency "libzip" not found, tried pkgconfig and cmake

But libzip IS listed as a pkgconfig package:

[vinicius@maclinux ~]$ pkg-config --list-all | grep libzip
libzip                         libzip - library for handling zip archives

And:

[vinicius@maclinux ~]$ pkg-config --libs libzip
-lzip 

Finally:

[vinicius@maclinux ~]$ ls -l /usr/include | grep zip.h
-rw-r--r--  1 root root  26491 mar  2  2021 zip.h

I'm stucked. I couldn't find any help in internet regarding libzip using together meson. I tried to just ommit libzip and a dependency but meson complains that it can't find zip.h.

I am running this in ArchLinux.

[UPDATE] If I compile manually using meson, it works. The problem occurs only inside GNOME Builder.

2

There are 2 best solutions below

0
On

If you can build directly with meson and cannot with GNOME builder - this points to missing PKG_CONFIG_PATH configuration in the latter case, i.e. environment variable with the list of paths where *.pc (pkg config files) are searched.

Check where libzip.pc is located:

$ apt-file search libzip.pc
$ libzip-dev: /usr/lib/x86_64-linux-gnu/pkgconfig/libzip.pc

I've never used GNOME builder but I found the following documentation page: Use Custom Sysroot.

By default pkg-config will search in /lib/pkgconfig and /usr/lib/pkgconfig but some sysroots install them in different locations. Debian-based use paths such as /usr/lib/x86_64-linux-gnu/pkgconfig. Other systems may use paths such as /usr/lib64/pkgconfig.

So, if libzip.pc in none of above, you should

... configure a new sysroot in Preferences -> SDKs to allow Builder to use it.

and it will land to ~/.config/gnome-builder/sysroot/general.conf

PS It could be also useful to check where all *.pc files located:

$ for f in $(locate *.pc); do dirname $f; done | uniq

and add these paths according to above.

0
On

If this a flatpak environment, you have to install libzip there. Open the flatpak JSON file and add your library to the modules section. Then it will be available in flatpak.