MySQLDBAPI

Daniel Dittmar daniel at dittmar.net
Tue Jun 14 18:16:12 EDT 2005


Gregory Piñero wrote:
> building '_mysql' extension
> gcc -pthread -shared build/temp.linux-i686-2.4/_mysql.o -lz
> -lmysqlclient_r -o build/lib.linux-i686-2.4/_mysql.so
> /usr/bin/ld: cannot find -lmysqlclient_r
> collect2: ld returned 1 exit status
> error: command 'gcc' failed with exit status 1

Now search for mysqlclient_r.so or mysqlclient_r.a (probably in 
rpmmysql/usr/lib.

A mysqlclient.so (without _r meaning without support for threading) will 
do as well if you use Python as a CGI program.

Now enter the directory where you found mysqlclient to setup.py
library_dirs = ['<your dir>']

If you found both .so and .a, rm the .so. The linker will then link the 
static library .a and you can copy the resulting _mysql.so everywhere.

If there is only an .so, be sure to copy the mysqlclient*.so to the 
server together with _mysql.so. You probably have to inspect the 
environment in your CGI run for LD_LIBRARY_PATH for a directory where 
you can copy mysqlclient*.so. (That's why it is easier to use the static 
library)

Daniel



More information about the Python-list mailing list