I'm stumped trying to compile MySQLdb on Solaris 9 SPARC. I compiled MySQL 4.1 and Python 2.3.5 from source using gcc for both (I'm pretty sure anyway). Anyone have any clues?
Does /usr/local/lib/mysql/libmysqlclient_r.so exist? If not, but libmysqlclient.so does, then you don't have the thread-safe libraries for some reason. Read README for how to use the non-thread-safe library.
I did as you recommended and there seems to be progress, but I am still having trouble. It appears to compile without error now, but it will not import in Python (see end of output). What I did:
In setup.py I actually changed the line:
mysqlclient = os.getenv('mysqlclient', 'mysqlclient_r')
To:
mysqlclient = os.getenv('mysqlclient', 'mysqlclient')
mnbweb6 # python setup.py install
running install
running build
running build_py
running build_ext
running install_lib
copying build/lib.solaris-2.9-sun4u-2.3/_mysql_exceptions.py -> /usr/local/lib/python2.3/site-packages
creating /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/init.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/converters.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/connections.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/cursors.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/sets.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/times.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/stringtimes.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/mxdatetimes.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/pytimes.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
creating /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/init.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/CR.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/FIELD_TYPE.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/ER.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/FLAG.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/REFRESH.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/CLIENT.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/_mysql.so -> /usr/local/lib/python2.3/site-packages
byte-compiling /usr/local/lib/python2.3/site-packages/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/init.py to init.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/converters.py to converters.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/connections.py to connections.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/cursors.py to cursors.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/sets.py to sets.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/times.py to times.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/stringtimes.py to stringtimes.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/mxdatetimes.py to mxdatetimes.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/pytimes.py to pytimes.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/init.py to init.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/CR.py to CR.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/ER.py to ER.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/CLIENT.py to CLIENT.pyc
mnbweb6 # python
Python 2.3.5 (#2, Apr 6 2005, 11:05:19) [GCC 3.3] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "MySQLdb/init.py", line 27, in ?
import _mysql
ImportError: ld.so.1: python: fatal: libmysqlclient.so.14: open failed: No such file or directory
>>>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem now is that the shared library is not on your default loader path. I'm not sure exactly how you would change this on Solaris.
Your other option is to use static linking. I neglected to put this in the README, but if you set the environment variable mysqlstatic=True, it should link against libmysqlclient.a.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm stumped trying to compile MySQLdb on Solaris 9 SPARC. I compiled MySQL 4.1 and Python 2.3.5 from source using gcc for both (I'm pretty sure anyway). Anyone have any clues?
Thanks,
Paul
The output of my failed attempt:
mnbweb6 # python setup.py build
running build
running build_py
creating build
creating build/lib.solaris-2.9-sun4u-2.3
copying _mysql_exceptions.py -> build/lib.solaris-2.9-sun4u-2.3
creating build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/init.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/converters.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/connections.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/cursors.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/sets.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/times.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/stringtimes.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/mxdatetimes.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
copying MySQLdb/pytimes.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb
creating build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.solaris-2.9-sun4u-2.3
/usr/local/bin/gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/mysql -I/usr/local/include/python2.3 -c _mysql.c -o build/temp.solaris-2.9-sun4u-2.3/_mysql.o -I/usr/local/include/mysql
/usr/local/bin/gcc -shared build/temp.solaris-2.9-sun4u-2.3/_mysql.o -L/usr/local/lib/mysql -lmysqlclient_r -lz -lpthread -lthread -lposix4 -lcrypt -lgen -lsocket -lnsl -lm -lpthread -lthread -lmysqlclient_r -o build/lib.solaris-2.9-sun4u-2.3/_mysql.so
ld: fatal: library -lmysqlclient_r: not found
ld: fatal: library -lmysqlclient_r: not found
ld: fatal: File processing errors. No output written to build/lib.solaris-2.9-sun4u-2.3/_mysql.so
collect2: ld returned 1 exit status
error: command '/usr/local/bin/gcc' failed with exit status 1
mnbweb6 #
Does /usr/local/lib/mysql/libmysqlclient_r.so exist? If not, but libmysqlclient.so does, then you don't have the thread-safe libraries for some reason. Read README for how to use the non-thread-safe library.
http://cvs.sourceforge.net/viewcvs.py/mysql-python/MySQLdb/README?only_with_tag=HEAD&view=markup
I did as you recommended and there seems to be progress, but I am still having trouble. It appears to compile without error now, but it will not import in Python (see end of output). What I did:
In setup.py I actually changed the line:
mysqlclient = os.getenv('mysqlclient', 'mysqlclient_r')
To:
mysqlclient = os.getenv('mysqlclient', 'mysqlclient')
Same as setting env variable, yes?
Here's the output:
mnbweb6 # python setup.py build
running build
running build_py
running build_ext
building '_mysql' extension
/usr/local/bin/gcc -shared build/temp.solaris-2.9-sun4u-2.3/_mysql.o -L/usr/local/lib/mysql -lmysqlclient -lz -lposix4 -lcrypt -lgen -lsocket -lnsl -lm -lmysqlclient -o build/lib.solaris-2.9-sun4u-2.3/_mysql.so
mnbweb6 # python setup.py install
running install
running build
running build_py
running build_ext
running install_lib
copying build/lib.solaris-2.9-sun4u-2.3/_mysql_exceptions.py -> /usr/local/lib/python2.3/site-packages
creating /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/init.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/converters.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/connections.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/cursors.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/sets.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/times.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/stringtimes.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/mxdatetimes.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/pytimes.py -> /usr/local/lib/python2.3/site-packages/MySQLdb
creating /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/init.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/CR.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/FIELD_TYPE.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/ER.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/FLAG.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/REFRESH.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/MySQLdb/constants/CLIENT.py -> /usr/local/lib/python2.3/site-packages/MySQLdb/constants
copying build/lib.solaris-2.9-sun4u-2.3/_mysql.so -> /usr/local/lib/python2.3/site-packages
byte-compiling /usr/local/lib/python2.3/site-packages/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/init.py to init.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/converters.py to converters.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/connections.py to connections.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/cursors.py to cursors.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/sets.py to sets.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/times.py to times.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/stringtimes.py to stringtimes.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/mxdatetimes.py to mxdatetimes.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/pytimes.py to pytimes.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/init.py to init.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/CR.py to CR.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/ER.py to ER.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling /usr/local/lib/python2.3/site-packages/MySQLdb/constants/CLIENT.py to CLIENT.pyc
mnbweb6 # python
Python 2.3.5 (#2, Apr 6 2005, 11:05:19)
[GCC 3.3] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "MySQLdb/init.py", line 27, in ?
import _mysql
ImportError: ld.so.1: python: fatal: libmysqlclient.so.14: open failed: No such file or directory
>>>
The problem now is that the shared library is not on your default loader path. I'm not sure exactly how you would change this on Solaris.
Your other option is to use static linking. I neglected to put this in the README, but if you set the environment variable mysqlstatic=True, it should link against libmysqlclient.a.
That did it! I set the env var LD_LIBRARY_PATH to include the shared library path and it now seems to work.
Many thanks for the help!
Also see this documentation, where you might find a better long-term solution:
http://docs.sun.com/app/docs/doc/817-3677/6mj8mbtbe?a=view#chapter3-10898