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

Following on from Devel::CheckOS I have been working with David Golden on Devel::CheckLib. It's similar to Devel::CheckOS, in that it will let module authors specify dependencies which aren't just other perl modules - if they need, eg, libjpeg, then they can use this module in Makefile.PL / Build.PL to make it a pre-req, and if it's missing then the CPAN testers will SHUT THE HELL UP ABOUT IT and not annoy the author.

It's still in something of a state of flux so not ready for real-world use yet, but we're at the stage where we need lots of people to beat it to hell and back. Please try to run the tests on as many platforms as possible, with as many perls as possible, and in particular using perls built with as many compilers and linkers as possible. Send the results - both successes and failures - to me by email along with the output from perl -V (that's a capital V).

We're particularly interested in results from people whose perl was built with something other than gcc or Microsoft C, as we don't have easy access to the proprietary Sun/SGI/DEC etc compilers or Borland C.

The more alert of you will have noticed that there is a bootstrapping problem in using this from within a Makefile.PL - relax, it will come with a script to bundle itself in an inc/ directory.

Replies are listed 'Best First'.
Re: Devel::CheckLib: Please break our code!
by perlfan (Parson) on Oct 19, 2007 at 14:00 UTC
    So how do we test it? Do we use it or do we install it via CPAN and let YOUR tests run? BTW, I just tried I can't get it via CPAN.

      You may need to wait until your CPAN mirror catches up. (Or switch to a mirror that updates more frequently.)

      As for testing, as a start, just try to install it using CPAN -- i.e. run our tests. Better yet, install and configure CPAN::Reporter first. That way, if it fails, we'll get notified automatically via CPAN Testers.

      Second, try it from the command line on some libraries on your system. Pick something you know you have and pick something you know you don't have.

      E.g., for me, with Strawberry Perl (Win32):

      C:\david\svk>perl -MDevel::CheckLib -e "assert_lib( lib => q{m} )" C:\david\svk>perl -MDevel::CheckLib -e "assert_lib( lib => q{jpeg} )" Can't build and link to 'jpeg'

      Or, on linux:

      $ perl -MDevel::CheckLib -e 'assert_lib( lib => "jpeg" )' $ perl -MDevel::CheckLib -e 'assert_lib( lib => "m" )' $ perl -MDevel::CheckLib -e 'assert_lib( lib => "iconv" )' Can't build and link to 'iconv'

      If it doesn't give you the results you expect for those libraries, let us know, along with your perl -V output.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        Thanks - I am going to test it out on AIX (xlc). I'll get back with the results once I have something for you.
Re: Devel::CheckLib: Please break our code!
by dk (Chaplain) on Oct 20, 2007 at 08:52 UTC
    I would appreciate a documented layout of the said prereq file, so Makefile.PL/Build.PL would not necessarily need to use Devel::CheckLib. The idea is great though.

    Also, I'm not sure if this is in the scope, but it would be great to have an option for a module to have a chance to re-run Makefile.PL after the missing dependencies were installed. Imagine one day someone releases something like bin::libjpeg.pm that installs libjpeg.so, and that can actually be used as an installable dependency.

      The bit that goes at the start of Makefile.PL (or Build.PL) looks something like this:
      use lib qw(inc); use Devel::CheckLib; # Prompt the user here for any paths and other configuration check_lib_or_exit( # fill in what you prompted the user for here lib => [qw(cthulhu fhtagn)] );
      While you could, in theory, extract all the relevant code from the module and put it straight into your Makefile.PL, there's a *lot* of it. Building and linking C code in a cross-platform way is a pain in the arse.
Re: Devel::CheckLib: Please break our code!
by Anonymous Monk on Oct 20, 2007 at 10:14 UTC