http://qs1969.pair.com?node_id=1205349

chrestomanci has asked for the wisdom of the Perl Monks concerning the following question:

Greetings wise brothers, I am trying to install Sys::Virt on a CentOS box. but perl cannot find the necessary header files.

I have installed the libvirt-devel package using yum, it has installed a number of header files in sensible places, as reported by "rpm -q -l libvirt-devel".

I have attemped to install Sys::Virt package both using cpanminus, and by hand (unpack the tarball run Makefile.PL, run the generated Makefile). Either way it reports that libvirt is not installed.

The check inside Makefile.PL is done using pkg-config. I have run that by hand and it also reports that libvirt is missing.

I tried editing Makefile.PL to remove the check, and running it anyway. It then spits out a Makefile, which when I run creates lots of errors about missing macros and symbols that are defined in the libvirt headers.

So in summary I have a situation where the CentOS core packaging system thinks the package has been installed, and has written the headers to the correct places. Meanwhile both pkg-config and the perl build system cannot find the package or the required header files, and so the build fails.

I know that the build system for compiling XS modules in C is correctly setup, because I have successfully installed other XS based modules including XML::LibXML and JSON::XS

At this point, I am stuck, so I am asking for help. Please bear in mind that I am not that familiar with CentOS (My preferred Distro is Debian), so I might have missed something obvious in the way that RedHat derived distros lay out files or configure libraries.

  • Comment on C headers not found when installing Sys::Virt on CentOS

Replies are listed 'Best First'.
Re: C headers not found when installing Sys::Virt on CentOS
by dasgar (Priest) on Dec 12, 2017 at 17:31 UTC

    Just want to point out that 'libvirt' and 'libvirt-devel' are two different RPM packages - at least they are for CentOS 7.2. You indicate that you are seeing messages about 'libvirt' not being installed. Out of curiosity, have you installed the 'libvirt' package?

      Took the words right out of my mouth. The "-devel" packages have headers used for compilation of code, but the libvirt package itself is what contains the drivers/binaries that you'll need for your project.

      Yes I did have the libvirt package installed as well, though I would have thought (but did not check) that it is a dependency of the '-devel' package, so will get installed automaticaly along with it.

Re: C headers not found when installing Sys::Virt on CentOS
by claviola (Novice) on Dec 12, 2017 at 17:50 UTC

    CentOS includes an RPM package for this module: perl-Sys-Virt

    If you want to build the latest version, I'd suggest fetching the source RPM and building a new one with the latest version of the module, or looking at what it is doing and replicating that.

      Thanks!

      That solves my problem a different and much simpler way.

      Is there an easy way to find out which perl CPAN modules are packaged for CentOS? I know about the website at http://deb.perl.it/ that works for Debian and Ubuntu packages. Is there an equivalent for CentOS or other RedHat derived distros?

        $ yum list perl-\*

        There are many such sites, but even my favorite, pkgs.org, is seriously lacking in search capabilities, so a search for Sys::Virt will come up empty.

        Therefore, I'd recommend just googling for rpm Module::Name instead.

        Note however that in this case you could have just searched with yum search Sys::Virt on your machine itself.

Re: C headers not found when installing Sys::Virt on CentOS
by syphilis (Archbishop) on Dec 13, 2017 at 10:18 UTC
    Meanwhile both pkg-config and the perl build system cannot find the package

    I've no experience of CentOS, but pkg-config will be looking for the file libvirt.pc, which would generally be in ../pkgconfig (relative to libvirt.a).

    Did installing the devel package install a libvirt.pc ? (If not that would be a problem for pkg-config.)
    Does pkg-config know where to find the .pc file ? (If not, then you set the PKG_CONFIG_PATH environment variable to the directory that houses the pc file ... and it should then find it.)

    Also, in my experience, builds involving pkg-config work flawlessly so long as pkg-config can find the relevant pc file.

    Cheers,
    Rob