Menu

CygWin compilation of 1.1.7 works

Help
crusty
2004-11-19
2012-09-19
  • crusty

    crusty - 2004-11-19

    Hi Ho out there...

    Looking around for a SSL supported version of MySQLdb
    on windows platforms (see thread "SSL troubles...")
    we noticed that the latest MySQL binary dist 1.0.0 for windows
    was neigther compiled with SSL support, nor raised an error to
    notice that missing SSL support when SSL was requested.

    Playing around with the farious versions on a FreeBSD system,
    everything worked fine (when MySQL (client AND server) was
    compiled with the --with-openssl option).

    The next step was trying to build the 1.1.7 source on
    my windows 2k machine with the CygWin GNU (gcc) compiler.

    1. Install CYGWIN_NT-5.0 1.5.12 or above
      Packages needed: Perl, Gcc, OpenSSL, OpenSSL-devel, Python2.3, make, and some other stuff...

    2. I first tried the mysql binary package, without success....
      so just recompile mysql under cigwin:

      2.1. Get CYGWIN_NT-5.0 1.5.12 or above
      Packages needed: Perl, Gcc, OpenSSL, OpenSSL-devel, Python2.3, make, and some other stuff...
      Get mysql-4.0.17-cygwin-src.tar.tar and unpack it

      2.2. Get http://anfaenger.de/cygwin-1.5/mysql/mysql-4.0.17-src.tar.bz2
      and unpack it.
      Remove all "#pragma interface" lines from the source.
      In the source directory:
      perl -i.rpi -pe 's/^#pragma interface.*$//;' \ fgrep -rl '#pragma interface' .

      2.3. Patch mysys/my_thr_init.c

      Original (lines #69-73):
      69: #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
      70: pthread_mutexattr_init(&my_errchk_mutexattr);
      71: pthread_mutexattr_setkind_np(&my_errchk_mutexattr,
      72: PTHREAD_MUTEX_ERRORCHECK_NP);
      73: #endif

      Change lines 71 & 72 to:

      ifdef CYGWIN

      pthread_mutexattr_settype(&my_errchk_mutexattr,
      PTHREAD_MUTEX_ERRORCHECK);

      else

      pthread_mutexattr_setkind_np(&my_errchk_mutexattr,
      PTHREAD_MUTEX_ERRORCHECK_NP);

      endif

      2.4. Configure the MySQL source
      (depending on your installation of the openssl you have to adapt
      the directory of the --with-openssl option!)

      CFLAGS="-O3" \ CC=gcc \ CXX=gcc \ CXXFLAGS="-O3 -mcpu=pentiumpro -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" \ ./configure \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var/mysql/data \ --libexecdir=/usr/sbin \ --with-unix-socket-path=/var/mysql/mysql.sock \ --with-openssl=/usr/local/openssl \ --with-vio \ --without-berkeley-db \ --without-innodb \ --without-debug \ --without-server \ --without-embedded-server \ 2>&1 | tee log.configure

      other possable (but not used) commands:
      --with-client-ldflags=-all-static \ --enable-thread-safe-client \ --with-mysqld-ldflags=-all-static \ --with-mysqld-user=mysqld \ --with-openssl-includes=/usr/include/openssl \ --with-openssl-libs=/usr/include/openssl \

      2.5. Compile and Install MySQL

      make 2>&1 | tee log.make
      make install 2>&1 | tee log.install

      2.6 Generate some Certificates and test the SSL support of the MySQL
      Installation.

    3.get the MySQLdb 1.1.7 source and upack it
    patch the following in the setup.py script:

    =>
    #mysqloptlibs = os.getenv('mysqloptlibs', '').split()
    mysqloptlibs = ['ssl', 'libssl', 'crypto', 'crypt', 'libcrypto']

    =>
    include_dirs =
    '/usr/local/include/mysql',
    '/usr/local/mysql/include',
    '/usr/local/mysql/include/mysql',
    '/usr/include/mysql',
    '/usr/include',
    '/usr/include/python2.3',
    '/usr/include/sys',
    '/usr/local/openssl/include',
    # Need for adapting the path for your opensll installation ?
    library_dirs =
    '/usr/local/lib/mysql',
    '/usr/local/mysql/lib',
    '/usr/local/mysql/lib/mysql',
    '/usr/lib/mysql',
    '/usr/local/openssl/lib',
    # Need for adapting the path for your openssl installation ?

    =>
    runtime_library_dirs = ['/usr/include/openssl', '/lib', '/usr/include/sys']

    =>
    extra_objects = ['/usr/local/openssl/lib/libcrypto.a', '/usr/local/openssl/lib/libssl.a']

    =>
    extra_compile_args = [] # '-mno-cygwin'
    extra_link_args = ['-LLIBDIR'] # '-mno-cygwin'

    =>
    elif sys.platform == "cygwin":
    include_dirs = ['/usr/include/mysql', '/usr/local/openssl/include', '/usr/include/sys']
    library_dirs = ['/usr/lib/mysql', '/usr/local/openssl/lib']
    libraries.extend(['wsock32', 'advapi32', 'libssl', 'libcrypto', 'crypto'])
    extra_compile_args.append('-DMS_WIN32')
    extra_objects = ['/usr/local/openssl/lib/libcrypto.a', '/usr/local/openssl/lib/libssl.a']

    1. compile it...

    python setup.py install

    it builds and install's proberly....

    1. Now comes the strange parts:
      It works for me under the CygWin environment ! But without SSL support =(
      a closer look on the _mysql.c source showed that it raised error when
      the HAVE_OPENSSL flag was not set, so i commented that HAVE_OPENSSL if's out
      recompiled that stuff,

    and YES it worked WITH SSL support !

    So MySQL or MySQLdb handles the HAVE_OPENSSL flag not the right way on windows....

    1. Looking forward to an 2.0.0 Binary dist for Windows

    Although it now looks nicer for the windows fellows,
    there are some troubles remaining ....

    I've tried to compile MySQLdb with the -mno-cygwin option,
    so it bypasses the need of cygwin1.dll and the cygwin environment.
    A binary that was compiled that way would not need to fire up cygwin
    every time you want to use that .EXE....

    With that option enabled, I ran in serious troubles last night:
    It tries to link against python, where a nightmare full of error's occours.

    I'm currently trying to build the python2.3 package myself, maybe it helps just
    like it helped on the MySQL issue....

    1. Are there any guys out there with Cygwin Python Mysql (and maybe MySQLdb) experience ?

    I would like to share some knowledge, so we could provide a 2.0.0 binary version for windows.

     
    • Andy Dustman

      Andy Dustman - 2004-11-22

      It is not necessary to change this line:

      mysqloptlibs = os.getenv('mysqloptlibs', '').split()

      Instead, run this in the shell before running setup.py:

      export mysqloptlibs='ssl libssl crypto crypt libcrypto'

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.