Building Perl modules for Solaris

This week I needed to install a few Perl modules on a Solaris 10 host. I didn’t want to download and install a fourth perl interpreter (Solaris 10 comes with 5.6.1, 5.8.3 and 5.8.4 for some reason), since Solaris 10 comes with a relatively recent version of Perl (5.8.4). To build the module in question (DBD::mysql), I downloaded the module from CPAN, verified that the MD5 checksum was correct, and used the following steps to compile the module:

$ perl Makefile.PL

$ make

$ make install

The ‘make Makefile.PL’ completed succesfully, but the make failed with the following errors:

$ make

cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm
cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm
cp lib/Mysql.pm blib/lib/Mysql.pm
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod
cp lib/Mysql/Statement.pm blib/lib/Mysql/Statement.pm
cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm
cc -c  -I/usr/perl5/site_perl/5.8.4/i86pc-solaris-64int/auto/DBI -I/home/apps/mysql/mysql/include/mysql -DDBD_MYSQL_INSERT_ID_I
S_GOOD -g  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO -xO3 -xspace -xildoff    -DVERSION=\"3.0006\"  -DXS_VERSION=\
"3.0006\" -KPIC "-I/usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE"   dbdimp.c
cc: unrecognized option `-KPIC'
cc: language ildoff not recognized
cc: dbdimp.c: linker input file unused because linking not done
/usr/bin/perl -p -e "s/~DRIVER~/mysql/g" /usr/perl5/site_perl/5.8.4/i86pc-solaris-64int/auto/DBI/Driver.xst > mysql.xsi
/usr/bin/perl /usr/perl5/5.8.4/lib/ExtUtils/xsubpp  -typemap /usr/perl5/5.8.4/lib/ExtUtils/typemap  mysql.xs > mysql.xsc && mv 
mysql.xsc mysql.c
Warning: duplicate function definition 'do' detected in mysql.xs, line 224
Warning: duplicate function definition 'rows' detected in mysql.xs, line 567
cc -c  -I/usr/perl5/site_perl/5.8.4/i86pc-solaris-64int/auto/DBI -I/home/apps/mysql/mysql/include/mysql -DDBD_MYSQL_INSERT_ID_I
S_GOOD -g  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO -xO3 -xspace -xildoff    -DVERSION=\"3.0006\"  -DXS_VERSION=\
"3.0006\" -KPIC "-I/usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE"   mysql.c
cc: unrecognized option `-KPIC'
cc: language ildoff not recognized
cc: mysql.c: linker input file unused because linking not done
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="/home/apps/mysql/mysql/lib/mysql:/lib:/usr/lib" /usr/bin/perl myld cc  -G dbdimp.o  mysql.o  -o blib/arch/auto/DBD
/mysql/mysql.so   -L/home/apps/mysql/mysql/lib/mysql -lmysqlclient -lz -lposix4 -lcrypt -lgen -lsocket -lnsl -lm   
cc: dbdimp.o: No such file or directory
cc: mysql.o: No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `blib/arch/auto/DBD/mysql/mysql.so'

Since I was building the module with gcc, the compiler and linker got a bit confused when they were passed Sun studio compiler flags (i.e., -KPIC in this example). There are two fixes for this problem. If you want to build a single module with gcc, you can edit the Makefile that was produced by ‘perl Makefile.PL’, and remove the “-KPIC” and “-xO3 -xspace -xildoff” values from the following variables:

$ egrep ‘(KPIC|O3)’ Makefile
CCCDLFLAGS = -KPIC
OPTIMIZE = -xO3 -xspace -xildoff

If you want to use gcc to build all Perl modules on a system, you can permanently* remove the Sun Studio compiler references by adjusting the “cccdlflags” and “optimize” variables in /usr/perl5/5.8.4/lib/sun4-solaris-64int/Config.pm:

$ egrep ‘(KPIC|O3)’ Config.pm
cccdlflags=’-KPIC’
optimize=’-xO3 -xspace -xildoff’

Since I don’t want to support two compiler packages, I decided to use option #2 since gcc comes on the Solaris installation CDs.

* If you edit Config.pm, you should be aware that Solaris Perl patches will overwrite this file.

13 thoughts on “Building Perl modules for Solaris”

  1. You should checkout perlgcc(1), which is specifically for dealing with the situation. You’ll need /usr/perl5/bin in PATH ( and /usr/perl5/man in MANPATH ).

    Ivan.

  2. The perlgcc module will not work with perl 5.8.4. See the README for Solaris-PerlGcc.

  3. perlgcc failed to install PathTools-3.24 on my sparc Solaris 10 system.
    I also got make errors when I tried matty’s edits in Config.pm. Gonna try installing Sun Studio, see how that works.

  4. You might also need to edit Config_heavy.pl (in the same dir as the Config.pm) to edit the flags and make CPAN.pm happy, since it is req’d in Config.pm. Another flag that might need removal is -xarch=386, it still complains with that present on an x2200.

  5. wrt previous comment, the perl version I used requiring the extra steps is not the one installed w/solaris, but a blastwave package, which does things a little different (thus the extra files and flags) and uses perl 5.8.8 .

  6. OK, I’m in the same boat as Tmack. I’m looking at the Config_heavy.pl, and I don’t like editing that crap. If I have to, I will post my results here.

  7. Great blog. I searched high and low for a solution to compiling DBD on Solaris 10. In the end I decided to go with the instructions in the following link: http://hivearchive.com/category/perl/

    After removing SUNW Perl (core) and CSWperl and installing the gcc compiled package from sunfreeware, DBI compiled without any issues.

  8. I got the DBI and DBD:Oracle modules compiled successfully with gcc 3.4.6 and perl 5.8.4 with the instructions mentioned here. However, while running, DBI is complaining with the following error:


    install_driver(Oracle) failed: Unable to get DBI state from DBI::_dbistate at 14d580. DBI not loaded. at /usr/perl5/5.8.4/lib/sun4-solaris-64int/DynaLoader.pm line 253.
    Compilation failed in require at (eval 4) line 3.

    Any pointers on what the problem could be?

  9. I am installing openCA.However,it can’t run.

    install_driver(mysql) failed: Unable to get DBI state function. DBI not loaded. at /usr/lib/perl5/DynaLoader.pm line 223.
    Compilation failed in require at (eval 294) line 3.

    Any pointers on what the problem could be?

Leave a Reply

Your email address will not be published. Required fields are marked *