Full disclosure: I've cross-posted this query to the MySQLdb sourceforge forum, but maybe someone over here can help.
I'm trying to build MySQLdb on a shared webserver in my user account, and I can't seem to properly link to the mysql shared libraries. So far I have built both python2.4 and mysql-5.0.37 from source to ensure compiler compatibility using gcc 3.2.3 20030502 (Red Hat Linux 3.2.3-58).
mysql was built as follows (I don't know what some of these flags do, but I followed advice in the mysql docs):
export INSTALLDIR=$HOME/mysql-5.0.37-linux
mkdir $INSTALLDIR
# see
http://dev.mysql.com/doc/refman/5.0/en/installing-source.html
export CFLAGS="-O3"
export CXX=gcc
export CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"
./configure --prefix=$INSTALLDIR --enable-assembler --enable-thread-safe --enable-shared
make
make install
One comment at this point is that --enable-thread-safe failed to generate mysqlclient_r as advertised in the mysql docs, so I proceeded below with threadsafe = False in site.cfg
Now I build MySQLdb:
## setup.py must be able to see mysql_config
export PATH=$HOME/mysql-5.0.37-linux/bin:$PATH
export INSTALLDIR=$HOME/lib/python2.4/site-packages/
export PYTHONPATH=$INSTALLDIR:$PYTHONPATH
mkdir -p $INSTALLDIR
$HOME/bin/python2.4 setup.py install --prefix=$HOME
The build proceeds without error, but when I try to import:
% $HOME/bin/python2.4 -c "import MySQLdb"
Traceback (most recent call last):
File "<string>", line 1, in ?
File "build/bdist.linux-i686/egg/MySQLdb/__init__.py", line 19, in ?
File "build/bdist.linux-i686/egg/_mysql.py", line 7, in ?
File "build/bdist.linux-i686/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.15: cannot open shared object file: No such file or directory
I clearly have built libmysqlclient.so.15:
~ % find ~/mysql-5.0.37-linux -name "libmysqlclient*"
/rc01/d94/ngh2/mysql-5.0.37-linux/lib/mysql/libmysqlclient.so.15.0.0
/rc01/d94/ngh2/mysql-5.0.37-linux/lib/mysql/libmysqlclient.so.15
/rc01/d94/ngh2/mysql-5.0.37-linux/lib/mysql/libmysqlclient.so
/rc01/d94/ngh2/mysql-5.0.37-linux/lib/mysql/libmysqlclient.la
/rc01/d94/ngh2/mysql-5.0.37-linux/lib/mysql/libmysqlclient.a
And it looks like this directory was at least mentioned in the compile code (partial output from setup.py install)
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/rc01/d94/ngh2/mysql-5.0.37-linux/include/mysql -I/rc01/d94/ngh2/include/python2.4 -c _mysql.c -o build/temp.linux-i686-2.4/_mysql.o
gcc -pthread -shared build/temp.linux-i686-2.4/_mysql.o -L/rc01/d94/ngh2/mysql-5.0.37-linux/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -o build/lib.linux-i686-2.4/_mysql.so
Yet clearly something didn't work correctly:
~ % ldd /rc01/d94/ngh2/build/MySQL-python-1.2.2/build/lib.linux-i686-2.4/_mysql.so
libmysqlclient.so.15 => not found
libz.so.1 => /usr/lib/libz.so.1 (0x0025b000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00292000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00bb2000)
libm.so.6 => /lib/tls/libm.so.6 (0x00162000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0013c000)
libc.so.6 => /lib/tls/libc.so.6 (0x00de8000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x008b7000)
Can someone help me put this together? I'm very much at the limit of my understanding of the compile process at this point.
Thanks a lot for any ideas,
Noah