简体   繁体   中英

How to determine the libudev version dynamically

I'm facing a difficulty of porting my drivers into different linux distributions because their libudev version is different.

Many linux distributions does have different libudev versions and libudev is known for breaking their interface without even changing it's 'soname'.

So we have write a wrapper for udev version and that wrapper library does uses udev version using 'pkg-config' wizard. But now when I'm running my drivers in different distributions like Kali Linux, I get to know that 'pkg-config' utility does not exists in some linux distributions like "Kali linux".

Now my drivers fail to operate because it depend on 'pkg-config' utility which can't be found in 'Kali Linux'. And there is no way that I could determine the libudev version without using 'pkg-config' utility. Even if I force my client to install 'pkg-config' utility some linux systems does not have a *.pc file so it also fails.

Any alternatives to this issue ? Is it oky to guess the libudev version by try to searching the functions declared in that library ? This is the only way that currently I have in my mind.

Thanks In Advance.

For the fact that libudev an pkg-config is there on live distributions. But it's name have been changed. Now you have to invoke.

pkg-config --modversion udev

instead of 'pkg-config --modversion libudev' , This is true for newest version of raspbian , kali and Ubunu distros which are seems to be debian based.

Update: I have fond another distribution which don't have pkg-config, in that case there is a tool called udevadm and it could be used to read it's libudev version.

which udevadm
if [ $? -eq 0 ]; then
    UDEV_VERSION=`udevadm --version`
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM