jump to navigation

Install DBD::mysql for Solaris 10 system perl August 13, 2009

Posted by claudio in Uncategorized.
Tags: , , , , ,
trackback

perlInstalling DBD::mysql on Solaris 10 seems to be less trivial than “cpan DBD::mysql” when you want to use the system-supplied perl (5.8.4) and mysql (4.0.31) installation. Google shows a lot of people asking how to proceed, but surprisingly no answers. Typically, one gets this error at make time:

[...]
"dbdimp.c", line 4468: improper member use: com
"dbdimp.c", line 4468: improper member use: com
"dbdimp.c", line 4468: improper member use: com
"dbdimp.c", line 4630: undefined struct/union member: pmysql
"dbdimp.c", line 4653: undefined struct/union member: pmysql
cc: acomp failed for dbdimp.c
make: *** [dbdimp.o] Error 1

To install the module do this:

  1. Install the following Solaris mysql packages (if not already installed): SUNWmysqlr, SUNWmysqlu, SUNWmysqlS, SUNWmysqlt.
  2. Type the following as root:
    cd /usr/sfw/share/src/mysql
    ./configure
  3. Download the tar ball of the modules or, easier, go to your cpan build directory (set at cpan configure time), typically at ~/.cpan/build/DBD-mysql-<VERSION> (already there if you previously tried to install the module with cpan).
  4. Run the makefile with the following arguments (adapt to your own needs if necessary):
    cd ~/.cpan/build/DBD-mysql-<VERSION>
    perl Makefile.PL --libs '-R/usr/sfw/lib -R/usr/sfw/lib/mysql -L/usr/sfw/lib -L/usr/sfw/lib/mysql -lmysqlclient -lz -lposix4 -lcrypt -lgen -lsocket -lnsl -lm' --cflags '-I/usr/sfw/include -I/usr/include -I/usr/sfw/share/src/mysql/include'
  5. Complete the normal installation (make, make test (if you have a test db running), make install).

That’s it.

About these ads

Comments»

1. Henrique - April 13, 2010

I tried to follow the steps above, but I still had problems. I think it is related to the arguments passed to the makefile. It would help a lot if you could explain these arguments in more details.

2. Install DBD::mysql for Mysql 5 on Solaris 10 « *n*x - October 25, 2010

[...] the needed libraries and header files are often not installed on Solaris or found in weird places (Howto on installing DBD::mysql with Solaris supplied mysql 4.0.31 and perl 5.8.4). This post explains how [...]

3. Don Shuff - January 27, 2011

I’m running Oracle Solaris 9/10 and was about to try your method for installing DBD::mysql but I do not know where to find the package SUNWmysqlS. SUNWmysqlr, SUNWmysqlu, and SUNWmysqlt are already installed. Thank you for your help.

claudio - February 3, 2011

The package name is SUNWmysqlS (it is a pkg dir, install with “pkgadd -d .”) and can be found on the Solaris DVD.

4. Don Shuff - February 3, 2011

Found the package and your instructions above helped me to get DBD::mysql compiled. However, like so many others, I’ve found that “make test” fails with:

# Failed test ‘use DBD::mysql;’
# at t/00base.t line 21.
# Tried to use ‘DBD::mysql’.
# Error: Can’t load ‘/.cpan/build/DBD-mysql-4.018/blib/arch/auto/DBD/mysql/mysql.so’ for module DBD::mysql: ld.so.1: perl: fatal: relocation error: file /.cpan/build/DBD-mysql-4.018/blib/arch/auto/DBD/mysql/mysql.so: symbol mysql_get_server_version: referenced symbol not found at /usr/perl5/5.8.4/lib/i86pc-solaris-64int/DynaLoader.pm line 230.

According to the MySQL API documentation, the mysql_get_server_version function wasn’t added until MySQL version 4.1 so it’s not present in the stock Solaris 10 version. Since I did get it to compile from within the CPAN shell I just forced the install using:

cpan> force install DBD::mysql

and so far it seems to be working just fine. Hopefully this will help someone else getting the same error as I did.

5. petersblogwp - August 23, 2012

Guys, when on Solaris it is really important to use GNU tar and GNU make rather than the Solaris equivalents. When “building” modules it is also crucial that you use /usr/perl5/bin/perlgcc rather than just ‘perl’.

I’ve found this link for you that explains how to install CPAN modules on Solaris 10 and Solaris 11.

http://twiki.org/cgi-bin/view/Codev/SolarisInstallCookbookPerlModules

The above guide also explains why it is crucial to use ‘perlgcc’.

6. petersblogwp - August 23, 2012

I forgot to be more clear in my previous post : I’m 99% convinced that the problems you see (and the tedious workarounds you’ve had to come up with) are because you do not use GNU tar and GNU make and because you do not use ‘perlgcc’.

7. claudio - August 23, 2012

Peter,

In this case the problem is rather on the mysql libs part of the equation. I agree that cc can be a handful, but so far I haven’t had many problems when building perl and cpan modules with Sun Studio’s cc.

8. petersblogwp - August 24, 2012

Latest comment from claudio made me think.

I’ve had great difficulty installing DBD::mysql on Solaris 11 even when eating my own dog food as explained above (make sure to use GNU tar, GNU make and perlgcc (unless you have Sun Studio installed). But I eventually got it right. Here’s how.

My plan was to take as much as possible from the official Solaris IPS repository so I started out doing:

pkg install library/perl-5/database-512

This will give you the Perl DBI module, compiled by Oracle and ready to use with Solaris. It seems this is where Oracle stops. Their official IPS repository does not have for example DBD::mysql, which is somewhat strange given that they own MySQL. So you are on your own building that even on Solaris 11.

So I set out to build DBD::mysql and got lots of funny errors. It seemed to me that the build process was still insisting on using ‘cc’ options when compiling even if I specifically used ‘perlgcc’. Strange. However as it turns out this is because the build process for DBD::mysql picks up build instructions from the DBI module on which is depends and since this was compiled with ‘cc’ and not with ‘gcc’ it seemed not to matter that I tried to force the perl build process to use ‘gcc’ by using ‘perlgcc’. I would say that normally it doesn’t matter if you build additional perl modules using ‘gcc’ despite the fact that the rest of the perl installation was build using ‘cc’ but in this case it mattered.

So I bit the bullet and installed Sun Studio (nowadays called Oracle Solaris Studio). It is a free install. As you would expect on Solaris 11 you can install that via IPS so it is rather painless, except that you first have to install a certificate in order to access the Sun Studio IPS repository which is separate from the general Solaris IPS repository. Instructions on the Sun Studio home pages. It only takes a minute to setup that extra IPS repository once and for all. Alternatively – if you don’t want to do it the IPS way – then Oracle still offers a good old tarball. I’m in love with IPS so for me there’s no doubt. (I never want to go back to Solaris 10 !). Anyway, sidetrack.

Once I had Sun Studio compiler installed I did:

export PATH=$PATH:/usr/mysql/bin:/opt/solarisstudio12.3/bin/

The mysql part of the PATH is so that the build process can find ‘mysql_config’ file. The solarisstudio part of the PATH is so it can find the ‘cc’ compiler.

I also did:

export CC=cc

Don’t know if I needed that.

Then finally I started the build like this:

perl -MCPAN -e ‘install DBD::mysql’

Notice I now deliberately do not use ‘perlgcc’, since I’m now in the fortunate situation that I have ‘cc’ installed.

You will see warnings during the compilation. This is usual and generally not to alarmed about. ‘cc’ is more strict about giving warnings on poorly written source (but semantically ok) than is the case for ‘gcc’.

So – despite the many warnings – it completed with success.

Bingo.

I can agree with claudio. On Solaris you can sometimes save yourself a lot of trouble simply by biting the bullet and installing the cc compiler instead of spending hours and hours trying to make it work with the gcc compiler.

9. claudio - August 24, 2012

Peter,

Maybe you should visit the #opencsw irc channel on freenode. There are people there working on compiling and packaging Solaris software. I try to help (and test) with Perl things there.

This is their website: http://www.opencsw.org/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 127 other followers

%d bloggers like this: