Compiling things against the Sun Web Stack MySQL

By Alasdair Lumsden on 6 Mar 2009

Sun have done an interesting thing with Web Stack 1.4, and have churned out both 32bit and 64bit libraries and binaries for Apache, PHP, MySQL, etc (On Solaris 10 anyway). The 64 bit versions can be found in their amd64 folders, and things like Apache & MySQL can be told to start in 64bit mode by tweaking their manifests. So for example, you have:

In: /opt/webstack/apache2/2.2/bin:

./httpd:    ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped
./amd64/httpd:      ELF 64-bit LSB executable AMD64 Version 1 [SSE FXSR CMOV FPU], dynamically linked, stripped

One downside of this is that Sun have forgotten a vital subtlety. There is a header file that ships with MySQL called “my_config.h”, which contains SIZEOF_ entries for the data types, eg SIZEOF_LONG. It’s autogenerated by autoconf, and the my_config.h that comes with Sun Web Stack 1.4 contains SIZEOF_ entries that are 64bit sized. There is no 32bit version of the file. This is no good if you want to link against MySQL in 32bit mode. We became aware of this error when compiling MySQL-python 1.3, which includes pyconfig.h as well, which also defines SIZEOF_LONG, so we were getting:

warning: "SIZEOF_LONG" redefined

There are perhaps ways of fixing or getting around this, such as stealing a my_config.h from a 32bit sized MySQL installation and altering the #include statement of whatever you’re compiling. But the safest solution we went with was to compile our own MySQL client from source, doing something along the lines of:

export CC=/opt/SUNWspro/bin/cc
export CXX=/opt/SUNWspro/bin/CC
./configure --without-server --enable-thread-safe-client --prefix=/opt/mysql_client
gmake install

You can then compile your application against this client library. A lot of things that build against mysql use the mysql_config program to get their compiler options. So if you do compile up your own mysql client, you’ll want to make sure it’s mysql_config is in your path.