LaKabane / libtuntap

The portable Tun/Tap devices configuration utility
193 stars 63 forks source link

Question: Includeing libtuntap with pkg-config #47

Closed marek22k closed 9 months ago

marek22k commented 9 months ago

Hello,

I would like to use libtuntap in my program. I use Meson, which in turn uses cmake and pkg-config to search for libraries. I have now built and installed libtuntap:

$ file /usr/include/tuntap++.hh
/usr/include/tuntap++.hh: C++ source, ASCII text
$ file /usr/include/tuntap++.hh
/usr/include/tuntap++.hh: C++ source, ASCII text
$ file /usr/include/tuntap.h
/usr/include/tuntap.h: C source, ASCII text
$ file /usr/lib/libtuntap++.a
/usr/lib/libtuntap++.a: current ar archive
$ file /usr/lib/libtuntap.a
/usr/lib/libtuntap.a: current ar archive

But when I try to find the library with pkg-config, it doesn't work. pkg-config --list-all | grep tuntap returns nothing.

Is there a mistake on my part? Is there a way to use the library with pkg-config?

I hope it's ok if I ask here.

tleguern commented 9 months ago

It is fine to ask here, no problem. We do not provide a .pc file for the project which is probably why you can't use pkg-config.

marek22k commented 9 months ago

Workaround / Alternative when using meson: https://github.com/mesonbuild/meson/issues/7281#issuecomment-932887170

cpp_compiler = meson.get_compiler('cpp')

libtuntap_dep = dependency('libtuntap', required: false)
if not libtuntap_dep.found()
    libtuntap_dep = cpp_compiler.find_library('libtuntap', has_headers: ['tuntap.h'], required: true)
endif
eli-schwartz commented 9 months ago

It would still be best to actually provide a pkg-config file. Using find_library is a hack to work around the lack of one, but it is not as flexible.