Compiling MySQL from source on Solaris 8


There are two purposes to the following page: SECTION 1: FOR THE USERS

USING SUN'S SFW FREEWARE
The SFWgcc package (from the Solaris 8 Companion CDROM) which includes gcc and g++ has one small flaw: it needs to be told to look in /opt/sfw/lib in order to compile some packages, including MySQL.

If you get an error such as: "checking return type of sprintf... configure: error: can not run test program while cross compiling" during configure, check to see if it seems to think c++ is a cross compiler. If so, then you need to override the configure's LDFLAGS. Do this via:

  $ export LDFLAGS='-R/opf/sfw/lib'

So, your compile process should look like:

  $ export LDFLAGS='-R/opt/sfw/lib'
  $ ./configure --prefix=/usr/local/mysql
  $ make
  $ su -
  # make install

That should do it for you!


USING SUNFREEWARE.COM'S FREEWARE
The new solution of exporting LDFLAGS also works with sunfreeware.com's version of gcc... except the flags are slightly different.

If you get an error such as: "checking return type of sprintf... configure: error: can not run test program while cross compiling" during configure, check to see if it seems to think c++ is a cross compiler. If so, then you need to override the configure's LDFLAGS. Do this via:

  $ export LDFLAGS='-R/usr/local/lib'

So, your compile process should look like:

  $ export LDFLAGS='-R/usr/local/lib'
  $ ./configure --prefix=/usr/local/mysql
  $ make
  $ su -
  # make install

That should do it for you!

Also, I've been told that installing GNU binutils will cause further problems, so keep this in mind.


SECTION 2: FOR THE DEVELOPERS

After fiddling with LD_LIBRARY_PATH and LD_RUN_PATH... the way to get it to compile (user side) is to export LDFLAGS='-R/opt/sfw/lib'. Therefore ONE way of fixing it code side is to have the configure script:
The better way to do it is to fix the configure script and various Makefiles to use CXXLDFLAGS, and then set CXXLDFLAGS=/opt/sfw/lib for Solaris users who have /opt/sfw in their compiler path. Currently the makefiles have a CXXLDFLAGS variable but do NOT use it (as far as I can see).

The history is as follows:
The initially fix was just to set LD_LIBRARY_PATH. This worked perfectly for compiling. The only problem was root had to have LD_LIBRARY_PATH set to launch the MySQL daemon, and users had to have LD_LIBRARY_PATH set to launch the MySQL client.

The next step up was setting LD_RUN_PATH prior to compiling and this worked as well. It also solved the problem of root needing to have it's LD_LIBRARY_PATH set in order to run the daemon, however, it did NOT fix the problem of users having to set LD_LIBRARY_PATH in order to run the client. This is because the client compilation has a -R flag that overrides LD_RUN_PATH.

The more complete fix is to bypass that by exporting the variable LDFLAGS. Instead of giving configure places to look for libraries, it forces configure to pass specific flags to libtool (specifically -R/opt/sfw/lib), and thus the binaries get compiled knowing where to look for their libraries.
Extra special thanks to Phil Brown for doing most of the work behind this. This solaris expert has a very valuable Solaris site at http://www.bolthole.com/solaris/.

Last Updated: 09/24/01

This page is © Phil Dibowitz 2001 - 2004