468,132 Members | 1,540 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,132 developers. It's quick & easy.

Installing MySQLdb under Cygwin

Hi,

I'm having trouble installing MySQLdb 0.9.2 on the following Cygwin system:
- Python 2.2.2
- MySQL 3.23.57
- gcc 2.95.3-10

The steps I take are:
1. Modify setup.py
- Set thread_safe_library = NO
- Change the Cygwin paths to use /cygdrive/c/...
- Change the library path to .../lib/opt

2. Run setup.py build
--> Errors on lines 2005-7 and 2094-6 of _mysql.c:
"Initializer element is not constant"

3. Replace the above lines with "0,"

4. Run setup.py build
--> Many undefined references to mysql functions

5. Change setup.py to use mysql library instead of mysqlclient

6. Run setup.py build
--> It compiles, so I run the setup.py install

7. When I try to import the library, I get the following error:
Traceback (most recent call last):
File "./test.py", line 4, in ?
import MySQLdb
File "MySQLdb/__init__.py", line 27, in ?
import _mysql
ImportError: dlopen: Win32 error 127

I'm stuck. I've tried using g++ instead of gcc, which gets rid of the
Initializer element is not constant" error. But I end up at the same error
when I try to import the module.

I have seen some posts from people who have managed to install MySQLdb on
Cygwin - could someone please let me know how to do it?

Kind regards,

Per
Jul 18 '05 #1
4 6182
Per,

On Fri, Oct 10, 2003 at 11:09:17AM -0700, Perflubron wrote:
7. When I try to import the library, I get the following error:
Traceback (most recent call last):
File "./test.py", line 4, in ?
import MySQLdb
File "MySQLdb/__init__.py", line 27, in ?
import _mysql
ImportError: dlopen: Win32 error 127
We have the following:

$ fgrep 127 /usr/include/w32api/winerror.h | head -1
#define ERROR_PROC_NOT_FOUND 127L

This error usually means the extension module did not export the init
function. What do you get when you try the following?

$ objdump -p _mysql.dll | fgrep init

For example:

$ objdump -p zlib.dll | fgrep init
[ 0] initzlib

If the init function is not being exported, then change the source from:

void
init_mysql(void)
{
...
}

to:

DL_EXPORT(void) /* for Python 2.2.2, use PyMODINIT_FUNC for Python 2.3+ */
init_mysql(void)
{
...
}
I have seen some posts from people who have managed to install MySQLdb
on Cygwin - could someone please let me know how to do it?


See the following mailing list thread:

http://cygwin.com/ml/cygwin/2003-10/msg00462.html

Try the Cygwin list if you need more help.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6

Jul 18 '05 #2
Hi Jason,
This error usually means the extension module did not export the init
function. What do you get when you try the following?

$ objdump -p _mysql.dll | fgrep init
I get:

ba58 52 mysql_init
[ 0] init_mysql__Fv

I don't know what the __Fv means.
If the init function is not being exported, then change the source from:

to:

DL_EXPORT(void) /* for Python 2.2.2, use PyMODINIT_FUNC for Python 2.3+ */
init_mysql(void)
{
...
}


The source already has the DL_EXPORT line in it.

I'll try the cygwin list now, thanks for your help.

Per
Jul 18 '05 #3
Per,

On Mon, Oct 13, 2003 at 01:53:48AM -0700, Perflubron wrote:
I get:

ba58 52 mysql_init
[ 0] init_mysql__Fv

I don't know what the __Fv means.


The "__Fv" is the name mangling produced by g++. Try again with gcc.
Or, add 'extern "C"' to the init function definition. What does objdump
indicate now?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6

Jul 18 '05 #4
Hi Jason,
The "__Fv" is the name mangling produced by g++. Try again with gcc.
Or, add 'extern "C"' to the init function definition. What does objdump
indicate now?


g++ with extern "C" does not compile at first attempt. With gcc, I
overcame the "initializer element is not constant errors" by setting
the elements of the struct after creating it, e.g:

_mysql_ConnectionObject_Type.tp_alloc = &PyType_GenericAlloc;

But the objdump is still the same:
ba58 52 mysql_init
[ 0] init_mysql

I've given up on using MySQLdb under Cygwin. I instead installed the
Windows version of Python and MySQLdb, and will use that combination
for certain scripts.

Thanks for all your help!

Per
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by dw | last post: by
reply views Thread by Bob Swerdlow | last post: by
reply views Thread by matthew collins | last post: by
7 posts views Thread by Matthias Verniers | last post: by
reply views Thread by Michael Boldin via alt email | last post: by
reply views Thread by martin.laloux | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.