installation1Add my vote for this tag solaris1Add my vote for this tag create new tag
, view all tags

Building CPAN Perl modules on Solaris 10 (and 11)

Why Solaris is different than Linux in this respect

Building CPAN modules on Solaris might be a bit different than on your average Linux platform. Here is the reason why:

Solaris 10 comes pre-installed with Perl 5.8.4. This is the good news. However, it has been built with Sun's Studio compiler suite. When perl is built it saves the name of the compiler and any compiler flags in its configuration files, and then uses these saved settings when any additional modules are built. So when you try to build additional modules it will expect to find the Sun Studio compiler.

Solaris 10 comes pre-installed with GNU C/C++ compiler but the Sun Studio compiler is optional and is likely not installed.

Luckily Solaris comes with a tool called perlgcc that fixes this problem. It will make sure that modules are build with gcc rather than the Sun Studio compiler. Instead of invoking perl Makefile.PL to generate the makefile needed to compile a module, perlgcc Makefile.PL should be used instead. All command-line arguments to perlgcc are passed unmodified to perl.

Needless to say you can forget all in this article if you have Sun Studio compiler installed and wish to use that for building modules. However most Perl modules have only been tested to compile with the GNU C/C++ compiler so if you do not want trouble stick with the recipe in this article.

Where to install Perl modules

During install you need to decide if you want to install CPAN modules into the standard system-wide location or to special location. There may be (at least) two reasons that you want to do the latter:

  1. You do not have privilege to install perl modules into the system-wide location.
  2. You wish to keep your default Perl installation clean and have a clear overview of what has been installed only for the sake of TWiki.
Note: The remainder of this document assumes that your want to install TWiki related Perl modules into /apps/twiki-root/perlmodules.

Manual install method

Note: The automated method described below is an aternative and is preferred. It will save you a lot of time.

These are the general steps to follow when installing a CPAN module manually on your TWiki host:

  1. Make sure gcc can be found. On a default Solaris install the gcc is in /usr/sfw/bin. Add this to your path if it is not already there. Check using the which command.
  2. If you plan to install into a special location then you need to make sure Perl reads modules from this location before continue with the steps below. This is done by
    $ PERL5LIB=$PERL5LIB:/apps/twiki-root/perlmodules
    $ export PERL5LIB
  3. Download the package from CPAN and unpack into a temporary directory.
  4. $ /usr/perl5/bin/perlgcc Makefile.PL LIB=/apps/twiki-root/perlmodules PREFIX=/apps/twiki-root/perlmodules
  5. $ /usr/sfw/bin/gmake MAKE=/usr/sfw/bin/gmake
  6. $ /usr/sfw/bin/gmake MAKE=/usr/sfw/bin/gmake test
  7. $ /usr/sfw/bin/gmake MAKE=/usr/sfw/bin/gmake install
  8. Remember to remove the temp directory.
  9. To view the modules installed in this special location, use
    $ grep :: /apps/twiki-root/perlmodules/sun4-solaris-64int/perllocal.pod
Note how we force the make process to use GNU make rather than the Sun equivalent.

Automated install method (preferred)

These are the general steps to follow when installing a CPAN module automatically using the CPAN shell script. This script will automatically download, make and install Perl modules for you. It can use a range of different tools to download depending on what is installed on host. It can access the CPAN repository by either ftp or http.

The suggestion below is to use http to access the CPAN repository and force the shell script to use the wget tool to download rather than any other alternative.

  1. Make sure gcc can be found. On a default Solaris install the gcc is in /usr/sfw/bin. Add this to your path if it is not already there. Check using the which command.
  2. If you plan to install into a special location then you need to make sure Perl reads modules from this location before continue with the steps below. This is done by
    $ PERL5LIB=$PERL5LIB:/apps/twiki-root/perlmodules
    $ export PERL5LIB
    Recommend to put the above into your login script.
  3. The following step will need to access the internet. Therefore make sure to let Solaris know your proxy settings (if any) beforehand:
    $ http_proxy=myproxy:80; export http_proxy
  4. Start the CPAN shell script: /usr/perl5/bin/perlgcc -MCPAN -e shell. If this is the first time this script is run it will ask a lot of questions and store the results in $HOME/.cpan/CPAN/MyConfig.pm. The file can edited by hand afterwards if need be. Here are some hints:
    1. Be sure to use GNU tools rather than Sun equivalents:
      'make' => q[/usr/sfw/bin/gmake],
      'tar' => q[/usr/sfw/bin/gtar],
    2. Make sure it uses wget and not anything else.
      'ftp' => q[],
      'ftp_proxy' => q[],
      'lynx' => q[],
      'ncftpget' => q[],
      'urllist' => [q[http://www.cpan.dk/]],
      'wget' => q[/usr/sfw/bin/wget],
    3. Set your proxy to access Internet (if required):
      'http_proxy' => q[myproxy:80],
    4. Install into special location:
      'makepl_arg' => q[LIB=/apps/twiki-root/perlmodules PREFIX=/apps/twiki-root/perlmodules INSTALLMAN3DIR=/apps/twiki-root/perlmodules/man/man3],
  5. Exit the script: exit
The above was one time only. Now you are ready to install Perl modules the easy way:

  1. Start the CPAN shell script: /usr/perl5/bin/perlgcc -MCPAN -e shell.
  2. Install a module, e.g.: install CGI::Session
  3. Exit the shell script: exit

Solaris 11 experience

This section has been added by Brian Martin.

On Solaris 11 the above is stil true, i.e. the fact that the installed Perl was build using Solaris Studio compiler and that you therefore need to use perlgcc when building/installing additional Perl modules. However there are some minor differences to Solaris 11 mainly in the area of paths and secondly your Perl version will be newer and also come with a somewhat never CPAN module compared to the one delivered with Solaris 10.

Here is an account of what I did:

If you are inside a non-global zone then it is very likely that this zone has been installed with the "small server" manifest as this is the default in Solaris 11. This means that you will have to add some packages even if these are indeed available in the global zone.

So very likely your zone does not have a C compiler and some Perl modules will require a C compiler during the install phase. Fear not. Simply install the GNU C/C++ compiler:

pkg install system/header
pkg install gcc-45

After this gcc will immediately become part of your PATH because it lives in /usr/bin (unlike in Solaris 10).

Furthermore I wanted to make sure my Perl module builds would be using GNU make and GNU tar (as opposed to the Solaris equivalents) so I also did this:

pkg install developer/build/gnu-make
pkg install archiver/gnu-tar

I wanted to do a self-contained library of needed Perl modules for TWiki so before I started I defined my !PERL5LIB as follows:

export PERL5LIB=/apps/twiki-root/perlmodules

In other words: I set out to install Perl modules as non-root. Admittedly this then becomes just as much a guide on how to install Perl modules as a non-root user as it is a guide specific to Solaris. Just so you know.

Here we go: I did first time start of CPAN as described above, answered the questions and exit'ed the CPAN shell. The Perl CPAN module stores preferences in ~/.cpan/CPAN/MyConfig.pm. I customized this file as follows:

  'make' => q[/usr/bin/gmake], 
  'make_install_make_command' => q[/usr/bin/gmake], 
  'makepl_arg' => q[LIB=/apps/twiki-root/perlmodules PREFIX=/apps/twiki-root/perlmodules INSTALLMAN3DIR=/apps/twiki-root/perlmodules/man/man3], 
  'mbuild_arg' => q[--install_base /apps/twiki-root/perlmodules], 
  'mbuild_install_arg' => q[--install_base /apps/twiki-root/perlmodules], 
  'mbuildpl_arg' => q[--install_base /apps/twiki-root/perlmodules], 
  'prefs_dir' => q[~/.cpan/prefs], 
  'tar' => q[/usr/bin/gtar], 

In the above I only mention those preferences that I edited by hand. The rest was set during the initial question-and-answer phase and were ok for my usage.

Some explanation of the reasonings for my customisations to the CPAN preferences:

  1. The preferences named make, make_install_make_command and tar simply make sure that I use the GNU tools as opposed to the Solaris equivalents. You might experience that you do not need this, i.e. that the Solaris equivalent tools will work just as well, but there's no reason to take the chance.
  2. The preference named prefs_dir. This - for some reason - had defaulted to some system directory where I obviously do not have write access. So I had to set it as above.
  3. The preferences named makepl_arg, mbuild_arg, mbuild_install_arg and mbuildpl_arg make sure that I tell the build subsystem where I want to install. Nowadays the Perl CPAN module use two different build sub-systems. The original is called ExtUtils::MakeMaker and it corresponds to the makepl_arg preference. The newer one is called Module::Build and it corresponds with the mbuild* preferences. Since some Perl modules use the old build system while others use the new you have to cater for both when you customize the CPAN preferences. As you can see on my preferences for mbuild ( Module::Build) I furthermore need to specific about the fact that I want to use gcc even if I start my session using perlgcc. I'm afraid I do not know enough about Perl build systems to explain if this could have been done differently or more elegant but at least the preferences described here will work.
With these customisations I could then install Perl modules as described above for Solaris 10, meaning:

$ /usr/perl5/bin/perlgcc -MCPAN -e 'install <module name>'

An example might be:

$ /usr/perl5/bin/perlgcc -MCPAN -e 'install CGI::Session'

After I installed all the Perl modules I needed I had to define my PERL5LIB env var as follows:

export PERL5LIB=/apps/twiki-root/perlmodules:/apps/twiki-root/perlmodules/lib/perl5

Note the second part which is required solely for CGI::Session. Perhaps this can give somebody an idea if I have done something wrong or if this is just the way it is.

While I did all this I continously used this little cheat script to test the status of the Perl modules I needed for TWiki 5.1.1. It was just a convenient way for me to do testing. That's all.

(end of Brian Martin addition for Solaris 11)

-- Contributors: Lars Haarber - 30 March 2008, Brian Martin - 30 April 2012


When I get to line 4 of the manual install directions I get an error that the perl script Makefile.PL cannot be found. I'm an intern tasked with prototyping Twiki for my company so I'm new to Solaris administration. My intuition is that I need to either be in a different directory when I call the command or I need to add something to my PATH. When I try to use this command my current directory is still the temporary directory I unzipped the module into in step 3.

-- StevePJohnson - 03 Jul 2008

I figured out what my problem was. I had started with CGI::Session since this was the first module listed in the Solaris install cookbook. For that particular module, not everything I needed was included in the most recent version of the module. I went back a few versions and found one package that had everything (including the makefile) and I got it installed properly.

-- StevePJohnson - 18 Jul 2008

Edit | Attach | Watch | Print version | History: r19 < r18 < r17 < r16 < r15 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r19 - 2012-05-24 - BrianMartinUK
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.