martinpitt / umockdev

Mock hardware devices for creating unit tests and bug reporting
https://launchpad.net/umockdev
GNU Lesser General Public License v2.1
312 stars 58 forks source link

How to build on pi? #142

Closed lucaswxp closed 3 years ago

lucaswxp commented 3 years ago

Hey guys.

I'm running maven trying to build it, but it complains I have no libpcap installed:

Run-time dependency gio-unix-2.0 found: YES 2.68.0
Run-time dependency libudev found: YES 241
Found CMake: /usr/bin/cmake (3.16.3)
WARNING: CMake Toolchain: Failed to determine CMake compilers state
Run-time dependency libpcap found: NO (tried pkgconfig and cmake)

meson.build:50:0: ERROR: Dependency "libpcap" not found, tried pkgconfig and cmake

A full log can be found at /app/umockdev-0.16.2/build/meson-logs/meson-log.txt

But apt-cache show libpcap-dev shows I have it:

Package: libpcap-dev
Source: libpcap
Version: 1.8.1-6
Architecture: armhf

I even tried to build libpcap from source (http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz), but didn't work either.

Any help on how can I instruct umockdev to find libpcap?

martinpitt commented 3 years ago

I suppose you mean "meson", not "maven". libpcap-dev is exactly right, that's what the official Debian package uses. So maybe you can just use the Raspbian package? Debian testing has the latest version, debian 11 is a little behind (0.15.4), but that may just be enough for you.

apt-cache show libpcap-dev does not show you the installed package, but the available one. Can you please check with dpkg -s libpcap-dev if you have it installed? Also, do you have pkg-config installed?

lucaswxp commented 3 years ago

Sure.

dpkg -s libpcap-dev:

Package: libpcap-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 34
Maintainer: Romain Francoise <rfrancoise@debian.org>
Architecture: armhf
Multi-Arch: same
Source: libpcap
Version: 1.8.1-6
Depends: libpcap0.8-dev

And:

dpkg -s pkg-config

Package: pkg-config
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 169
Maintainer: Tollef Fog Heen <tfheen@debian.org>
Architecture: armhf
Multi-Arch: foreign
Version: 0.29-6
Replaces: pkg-config-bin
Depends: libc6 (>= 2.4), libglib2.0-0 (>= 2.16.0), libdpkg-perl
Suggests: dpkg-dev
Conflicts: pkg-config-bin
Conffiles:
 /etc/dpkg/dpkg.cfg.d/pkg-config-hook-config 467c877de00898418a9b26d432a1719a
lucaswxp commented 3 years ago

I don't know if this is relevant but my $PKG_CONFIG_PATH is /usr/local/lib/pkgconfig which doesn't exists.

I also have /usr/lib/pkgconfig which exists but it's empty.

lucaswxp commented 3 years ago

A little more information, sorry for not sending all at once.

pkg-config --variable pc_path pkg-config:

/usr/local/lib/arm-linux-gnueabihf/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig

I checked all these folder, none of them have libpcap on them.

Running ldconfig -p | grep libpcap gives:

    libpcap.so.0.8 (libc6,hard-float) => /lib/arm-linux-gnueabihf/libpcap.so.0.8
    libpcap.so (libc6,hard-float) => /lib/arm-linux-gnueabihf/libpcap.so
martinpitt commented 3 years ago

So that means that pkg-config --modversion libpcap fails even though the package is installed. This is a local configuration problem. Can you try without $PKG_CONFIG_PATH?

lucaswxp commented 3 years ago

I tried:

export PKG_CONFIG_PATH=
meson setup build/

Same thing.

Any ideas what may cause this? I managed build libpcap from source, is there any way to point to it? Even if I have to modify the meson.build file. Any help is appreciated.

martinpitt commented 3 years ago

As I said, you need to install things and set up $PKG_CONFIG_PATH to a place where pkg-config --modversion libpcap can find them (this is a much faster and more direct test than trying to build umockdev). You really don't have to build libpcap from source unless you want to modify something.