Compiling perl modules on Solaris 10

Note: See an updated discussion about using a Sun vs. Sunfreeware build environment here. Because this post involves building modules against the shipping perl from Sun, I used a Sun build environment.

These are just some random notes for now. Will come back and polish later.

Solaris 10 comes with its own build of perl 5.8.4, with the main executable at /usr/bin/perl and most of the rest under /usr/perl5. This is compiled to 32-bit using Sun’s own developer toolchain, and so new modules need to be installed using that toolchain.

That means the developer packages need to be installed, giving you both a /usr/ccs and /usr/sfw. Goodies in /usr/sfw include gcc. Of course /usr/ccs has it’s own make and trusty old ld linker.

To successfully build modules the build user’s environment should be:

PATH=/usr/sfw/bin:/usr/ccs/bin:/usr/local/bin:/usr/local/ssl/bin:$PATH
LD_LIBRARY_PATH=/usr/sfw/lib:/usr/ccs/lib:/usr/local/lib:/usr/local/ssl/lib:$LD_LIBRARY_PATH

Modules need to be built using this command line (CPAN install will fail much of the time):

/usr/perl5/bin/perlgcc Makefile.PL -Dcc=gcc

The perlgcc executable was specially created to allow building of modules with Sun’s gcc.

Some modules (that use MakeMaker) won’t accept the “-Dcc=gcc” parameter.

For Text::Iconv, for example, I had to include

LIBS=’-L/usr/local/lib” INC=’-I/usr/local/include’

on the command line after Makefile.PL because it (the configuration script) was confused about which iconv I wanted.

Here’s the response I got:

Have /usr/perl5/5.8.4/lib/Sun/Solaris/PerlGcc
Want /usr/perl5/5.8.4/lib/sun4-solaris-64int
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [PerlGcc]
Config says: [sun4-solaris-64int]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Writing Makefile for Text::Iconv

Well, it passed make and make test so I went ahead and installed.