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.
July 30th, 2006 at 12:01 am
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.
July 30th, 2006 at 12:30 am
See also the “Solaris-PerlGcc” module - you end up with a “perlgcc” command you use when you run CPAN. a tiny bit more fiddly perhaps, but works just as well.
http://search.cpan.org/~aburlison/Solaris-PerlGcc-1.3/
August 1st, 2006 at 5:25 pm
The perlgcc module will not work with perl 5.8.4. See the README for Solaris-PerlGcc.
August 1st, 2006 at 5:30 pm
perlgcc is included in solaris 10. /usr/perl5/bin/perlgcc
April 5th, 2007 at 7:37 pm
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.
January 9th, 2008 at 7:53 pm
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.
January 9th, 2008 at 8:37 pm
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 .
February 29th, 2008 at 7:30 pm
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.