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

I have used perlbrew to install a new version of perl and all works well. I can install most modules from CPAN without a problem. However, I don't know how to install external libraries - e.g. libgd - in a way that my new perl can find them. Up to this I was using MacPorts for this purpose but it installs the libraries in /opt/local/ and compiles them against the version of perl found there. Any help would be most appreciated.

Update: Thanks to taint and syphilis, and a simple question from anony monk, I have it working now. I can continue to install external libraries using MacPorts and adding the following line to my bash profile

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Then, when installing modules I invoke cpan with my perlbrew perl (this was my lightbulb moment believe it or not)
sudo /Users/user/perl5/perlbrew/perls/perl-5.14.1/bin/perl5.14.1 -MCPA +N -e shell
and all is hunky dory, modules get installed in my perlbrew path and can use the libraries installed in my MacPorts path.

Replies are listed 'Best First'.
Re: Installing external libraries for perlbrew perl
by syphilis (Archbishop) on Dec 19, 2013 at 02:57 UTC
    However, I don't know how to install external libraries - e.g. libgd - in a way that my new perl can find them

    I think most people attack this the other way around - they build their perl in such a way that it automatically finds the existing external libraries by, eg, ensuring that the path to these external libraries is built into $Config{libpth}. (Running perl -V:libpth will print out the existing value of $Config{libpth}.)
    Not sure how you'd achieve that with perlbrew - I build perl often enough, but I don't use perlbrew (and I doubt that I ever will).

    Another option that should work if you're using a gcc compiler is to set a couple of environment variables:
    export CPATH=/opt/local/include:$CPATH export LIBRARY_PATH=/opt/local/lib:$LIBRARY_PATH
    Does that second option work for you ?

    Cheers,
    Rob
      Hi Rob. perl -V:libpth gives me:
      libpth='/opt/local/lib /usr/lib';
      I have the gd library installed there but when I try to install GD.pm using cpan I get the error
      **UNRECOVERABLE ERROR** Could not find gdlib-config in the search path.
      Now I can see that gdlib-config is in /opt/local/bin. Is there any way to tell cpan that? Thanks
        Greetings, bangor.

        What shell area you using? Like sh, bash, csh, tcsh, zsh, etc. Chances are you should be able to simply open your terminal app, and do

        $PATH
        This will likely emit a long string. Which will contain all the directories within your search %PATH. Are any of the directories that you indicate your failed install(s) are complaining about, in the string of directories $PATH told you about?

        You do know that perlbrew messes with your {ENV}vironment, don't you? You should already have a "system" Perl installed -- that which the OS installed, as part of it's base. Your ENV determines which Perl is used, whenever you type "perl" in your terminal.

        At this point, I can't help but think your ENV is hosed. Not that it can't be corrected. But you will need to know which Perl you're running under. Because it makes all the difference, when using Perl, and when, and where to install Modules, and their dependencies.

        HTH

        --Chris

        Yes. What say about me, is true.
        
        is /opt/local/bin in $PATH?
Re: Installing external libraries for perlbrew perl
by Anonymous Monk on Dec 19, 2013 at 03:32 UTC
Re: Installing external libraries for perlbrew perl
by taint (Chaplain) on Dec 19, 2013 at 01:04 UTC
    Greetings, bangor.

    You were given some very informative links yesterday, from the other responder to your question. I'd strongly recommend reviewing them. In fact, they are related to what I'm going to suggest to you now. Firstly, you're going to have to read up on your version of make. The link I just used is for the FreeBSD version of make. You will want to issue the following within a terminal app, on your box

    man make
    this will inform you of options you can give any Modules, or libraries you choose to install. Another important command you will want to get acquainted with, is ldd. This utility is not unlike the dispatcher, at a cab company. It keeps inventory of all the cabs/cabbies (symbols, in OS/library speak). Then dispatches the cabs (symbols/library functions) on request. Or emits those wonderful error messages you've been asking about.
    man ldd
    should provide more than you want to know about ld. :)

    That's all there is to say, in the matter. Pay close attention to how you can inform/influence make, where library paths are concerned.

    Have fun, and get to reading. :)

    --Chris

    UPDATE; Forgot to mention; You'll also probably be well advised to read up on ld. As it's part of the ldd process. But you would already have noticed that, having read the ldd man page. :)

    In fact, it's more powerful, and influential than ldd!

    Yes. What say about me, is true.
    
      Hi Chris, thanks for your reply. I will check out those links. I think you are telling me that I will need to compile these libraries manually? btw, I think you are confusing me with someone else as I didn't ask any question yesterday.

        You'll understand better, once you've read up on make, and ldd. But in short; you will ultimately need to tell make where your /opt/... path is. Cause it sounds like that is where you are keeping your perlbrew libs at. But only you will have the answer to that. I don't have any real idea how your building things on your box. That's your job. :)

        Best wishes, and good luck.

        --Chris

        Yes. What say about me, is true.