Installing MySQLdb under Cygwin

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Perflubron

    #1

    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_lib rary = 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:
    "Initialize r 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
  • Jason Tishler

    #2
    Re: Installing MySQLdb under Cygwin

    Per,

    On Fri, Oct 10, 2003 at 11:09:17AM -0700, Perflubron wrote:[color=blue]
    > 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[/color]

    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 )
    {
    ...
    }
    [color=blue]
    > 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?[/color]

    See the following mailing list thread:



    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

    Comment

    • Perflubron

      #3
      Re: Installing MySQLdb under Cygwin

      Hi Jason,
      [color=blue]
      > 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[/color]

      I get:

      ba58 52 mysql_init
      [ 0] init_mysql__Fv

      I don't know what the __Fv means.
      [color=blue]
      > 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 )
      > {
      > ...
      > }
      >[/color]

      The source already has the DL_EXPORT line in it.

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

      Per

      Comment

      • Jason Tishler

        #4
        Re: Installing MySQLdb under Cygwin

        Per,

        On Mon, Oct 13, 2003 at 01:53:48AM -0700, Perflubron wrote:[color=blue]
        > I get:
        >
        > ba58 52 mysql_init
        > [ 0] init_mysql__Fv
        >
        > I don't know what the __Fv means.[/color]

        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

        Comment

        • Perflubron

          #5
          Re: Installing MySQLdb under Cygwin

          Hi Jason,
          [color=blue]
          > 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?[/color]

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

          _mysql_Connecti onObject_Type.t p_alloc = &PyType_Generic Alloc;

          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

          Comment

          Working...