Using App::cpanminus and PerlGcc to Install CPAN Modules on Solaris 10

If you have had the [dis]pleasure of deploying perl applications on Solaris, you probably have scores of tricks up your sleeve for installing pesky Perl modules. I find it necessary that application installations be scripted so I try to avoid anything that requires manual intervention.

Some modules on the CPAN will only install if you use gcc. Building CPAN Perl modules on Solaris 10 tells you how to use perlgcc to accomplish this. Pretty neat. I, admittedly, didn't know about perlgcc until today. It sure would have saved me a lot of headache over the years. I don't know how well it covers edge cases, and I'm sure there are pitfalls.

Let's take this a step further and see if we can get the perlgcc technique to work with cpanminus.

I've been loving cpanminus lately for many reasons. It's helped to avoid some of the obscure issues with installing CPAN modules, but mostly because it introduced me to local::lib. local::lib makes it simple to install Perl modules in alternative directories. This is absolutely necessary if you are using Solaris 10 sparse zones, in which you can't write to /usr, but you want to use the system perl.

I needed to install XML::CanonicalizeXML because it was a prerequisite for another module that I needed.

~> sudo /usr/bin/perl cpanm XML::CanonicalizeXML
Building and testing XML-CanonicalizeXML-0.03 for \
XML::CanonicalizeXML ... FAIL

# in build.log
cc: acomp failed for canon.c

This module failed to install when canon.c failed to compile using the Forte CC compiler installed on the server. Feel free to criticize the fact that I didn't (or couldn't) figure out why it failed to compile with the Forte compilers.

UPDATE: I eventually l figured out why XML::CanonicalizeXML didn't compile with Forte compilers. The source code of the C files had end of line characters that Forte CC didn't like. As a result, it was unable to properly parse the multiline macro in canon.c. It compiled after combining the multi-line macro to one line, or by running canon.c through dos2unix.

Taking the lazy way out, let's see what happens when I swap perl with perlgcc.

~> sudo /usr/perl5/bin/perlgcc cpanm XML::CanonicalizeXML
Building and testing XML-CanonicalizeXML-0.03 for \
XML::CanonicalizeXML ... OK                                          

FTW! I now have yet another technique for installing CPAN modules on Solaris. Time will tell if this technique will replace the other hacks that I have been using in the past.

1 Comment

I am content with sunfreeware perl which is also more recent than the system one. And I use gcc from the same source. Building perl modules is not too difficult with these prerequisites.

Leave a comment

About Jesse Thompson

user-pic I blog about Perl.