Compiling cx_Oracle/Oracle9i/Python 2.7/Windows

At the time of this writing, there is no Windows installer package for Oracle9i/Python 2.7 but compiling it yourself is pretty easy but it won’t compile correctly out of the box (At least it didn’t for me).

Your TODO List

The problem I ran into was that the newer version of GCC no longer supports the "-mno-cygwin" compiler directive.

Before running the standard “python setup.py” you’ll need to open and edit the file "cygwincompiler.py" which is located in PYTHONHOMELibdistutils

NoteTo be safe, you should either backup the "cygwincompiler.py" file or just copy the block of code and comment out the original.

Around line 322, you should see the block of code below…

self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
    compiler_so='gcc -mno-cygwin -mdll -O -Wall',
    compiler_cxx='g++ -mno-cygwin -O -Wall',
    linker_exe='gcc -mno-cygwin',
    linker_so='%s -mno-cygwin %s %s'
    % (self.linker_dll, shared_option, entry_point))

You’ll need to remove the references to the "-mno-cygwin" directive

self.set_executables(compiler='gcc -O -Wall',
    compiler_so='gcc -mdll -O -Wall',
    compiler_cxx='g++ -O -Wall',
    linker_exe='gcc',
    linker_so='%s %s %s'
    % (self.linker_dll, shared_option, entry_point))

Now run "python setup.py build"

then

Now run "python setup.py install"

HTH – ASDCore

,

  1. #1 by Mark on March 29, 2012 - 5:11 AM

    Hey. Thanks for this. I was having the same problem and found this through search. Worked great!

    • #2 by asdcore on March 29, 2012 - 10:07 PM

      No problem. Glad it worked for you.