Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

One way to install Perl's DBI/DBD modules UNIX
This may be kind of obscure, but if you're into Perl and trying to install modules via CPAN, specifically the DBI and DBD ones, things can get hairy. I spent a few hours trying to install these modules from source and from the CPAN perl shell. Neither worked, but gave frustrating errors that were impossible to track down. After a bunch of testing, I found the solution:
  1. Install Fink.
  2. In a Terminal window, type fink list dbi or fink list dbd and you will see a list of available packages.
  3. Now type fink install dbi-pm586 (that's the default DBI package for Perl 5.8.6)
  4. Here's the tricky part. Fink installs the modules in /sw -> lib -> perl5 -> 5.8.6 -> darwin-thread-multi-2level, which is not in your normal @INC when you run perl scripts. I'm sure you could recompile Perl to include Fink's installation directory, or move the files to the right places, but instead I found a different way. In your perl script, simply put:
    use lib '/sw/lib/perl5/5.8.6/darwin-thread-multi-2level';
    and Perl will look in the correct directory.
This solution eliminates the annoying CPAN - compiler - make errors for me.

[robg adds: A much older hint refers to some compiler issues with gcc3 that prevent the DBI and DBD modules from compiling. The hint claims that simply changing the compiler to gcc2 solves those issues. I'm not sure if that's still relevant to the issue in this hint, but it might be something to look at. In any event, using the Fink versions appears to be a valid workaround.]
    •    
  • Currently 4.00 / 5
  You rated: 5 / 5 (5 votes cast)
 
[16,187 views]  

One way to install Perl's DBI/DBD modules | 6 comments | Create New Account
Click here to return to the 'One way to install Perl's DBI/DBD modules' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
One way to install Perl's DBI/DBD modules
Authored by: kellert on Nov 08, '06 11:00:28AM

I agree, Fink is useful for some of the highly dependent perl modules. The good people at fink recommend editing your shell rc file though to include the fink path. Then you don't have to edit all your files with the use lib '/sw/...'; statemement. For bash you add this to .bashrc:
# set up fink env variables (including PERL5LIB, MANPATH, etc)
test -r /sw/bin/init.sh && . /sw/bin/init.sh

The init.sh script gets installed when you install fink.

---
T. Keller
OHSU - Portland, OR



[ Reply to This | # ]
One way to install Perl's DBI/DBD modules
Authored by: aschroed on Nov 08, '06 01:35:39PM

And for those still using tcsh add this to your .tcshrc file:

source /sw/bin/init.csh



[ Reply to This | # ]
One way to install Perl's DBI/DBD modules
Authored by: pckizer on Nov 08, '06 09:13:37PM
Those seem to be some hoops to jump through that are a bit overboard. I'd say just use MacPorts (previously DarwinPorts) instead, it's met the majority of my development needs without making me add any 'use lib's: (with the one caveat that the most recent release with the easy .dmg installer seems to be 1.3.1) and once MacPorts itself is installed, just install with this command:
  • port install p5-dbd-mysql


[ Reply to This | # ]
More!
Authored by: benholt on Nov 09, '06 06:29:19AM

Further developments:

Installing the modules from CPAN wasn't working because I was using an outdated version of the C compiler. You need version 4.0 or newer, so if you run "gcc_select" in the Terminal and it says anything else, you need to update your Developer Tools.

After I did this, I was able to install both modules using the CPAN function of Perl. However, there are still some that might give you trouble. Use Fink or what the other guy said :)



[ Reply to This | # ]
One way to install Perl's DBI/DBD modules
Authored by: barrettclark on Jan 01, '08 05:24:37AM

Interesting post. I never really was able to get Fink to properly work (and it was crazy slow when it did look like it was doing something). In fact, I'd like to uninstall Fink, but can't. I also can't update it anymore. It got itself corrupted and I can't make it go up or down.

If you can't get the compile to work in the CPAN shell, you can still use CPAN to download the package. Then exit out of CPAN to install it by hand. There are some modules where you pretty much have to do that anyway, or you have to have an external binary installed (eg. GD) for the module to use. It won't follow the dependencies with this method, which is one of the reasons to use something like CPAN or Fink in the first place, so it's not a great workaround.

I haven't played with new Perl modules lately, so it is in fact still broken on my new iMac. That's OK, though. I'm now a recovering perler....



[ Reply to This | # ]
One way to install Perl's DBI/DBD modules
Authored by: admdikramr on Oct 14, '08 02:18:45PM

In 10.5 at least, there is a much more elegant way to do this:

/Library/Perl/5.8.8/AppendToPath

contains a list of directories that are automatically searched. So, just add

/sw/lib/perl5/5.8.8/darwin-thread-multi-2level

...and everything works perfectly.



[ Reply to This | # ]