I want to get access to Oracle DBs from my personal computer and there is a slight problem. It looks like compilation of cx_Oracle for Python is extremely difficult. I am running the latest Mac OS X 10.7 version (64-bits), I am also running the latest 2.7 Python from the python.org. I have tried several different recipes trying to compile cx_Oracle, but I am failing with every tutorial I can find. I have used 32-bit and 64-bit Oracle libraries, tried to build 32-bit and 64-bit cx_Oracle builds. I have tried to force Python working in 32-bit and 64-bit modes. I am trying all this different combinations to make it works and currently still cannot get it right.
Any tips? Instructions how it should be done?
Callback.c:186: error: expected expression before ‘OCIError’
Callback.c:186: warning: assignment makes pointer from integer without a cast
Callback.c:187: error: expected expression before ‘ub4’
Callback.c: In function ‘Callback_PrepareArgs’:
Callback.c:211: error: expected expression before ‘OCIStmt’
Callback.c:211: warning: assignment makes pointer from integer without a cast
Callback.c:212: error: expected expression before ‘OCIError’
Callback.c:212: warning: assignment makes pointer from integer without a cast
Callback.c:213: error: expected expression before ‘text’
Callback.c:213: warning: assignment makes pointer from integer without a cast
Callback.c:214: error: expected expression before ‘ub4’
lipo: can't figure out the architecture type of: /var/folders/46/qzxwrnls21lfj9px81zdx2j40000gn/T//cc16enzv.out
error: command 'gcc-4.2' failed with exit status 1
I managed to use Python 2.7 from python.org 64-bit version. I forced cx_Oracle to build only 64-bit binary and forcing to use correct Mac OS X SDK. distutils picks the wrong Mac OS X SDK, i.e. MacOSX10.6.sdk instead of MacOSX10.7.sdk. If you would check the output (OUTPUT), you can see that for the second command it's referring to both 10.6 and 10.7 SDK. Is there any problems how disutils picks Mac OS X SDK? I also import the library, but I am getting warning (WARNING). Any advices are very much welcomed.
export CFLAGS='-isysroot /Developer/SDKs/MacOSX10.7.sdk'
export ARCHFLAGS='-arch x86_64'
python2.7 setup.py build
python2.7 setup.py install
$ python2.7 setup.py build
building 'cx_Oracle' extension
gcc-4.2 -DNDEBUG -g -O3 -isysroot /Developer/SDKs/MacOSX10.7.sdk -arch x86_64 -I/Users/david/bin/instantclient_10_2/sdk/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cx_Oracle.c -o build/temp.macosx-10.6-x86_64-2.7-10g/cx_Oracle.o -DBUILD_VERSION=5.1.1
gcc-4.2 -bundle -undefined dynamic_lookup -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -isysroot /Developer/SDKs/MacOSX10.7.sdk -arch x86_64 build/temp.macosx-10.6-x86_64-2.7-10g/cx_Oracle.o -L/Users/david/bin/instantclient_10_2 -lclntsh -o build/lib.macosx-10.6-x86_64-2.7-10g/cx_Oracle.so -shared-libgcc
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle-5.1.1-py2.7-macosx-10.6-x86_64.egg/cx_Oracle.py:3: UserWarning: Module cx_Oracle was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cx_Oracle-5.1.1-py2.7-macosx-10.6-x86_64.egg/cx_Oracle.pyc, but /Users/david/bin/cx_Oracle-5.1.1 is being added to sys.path
Looks like 10.6 SDK is picked because Python was compiled using that SDK.
python-config cflags ldflags
-I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3
-L/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -ldl -framework CoreFoundation -lpython2.7 -u PyMacError Python.framework/Versions/2.7/Python
Edited by: user1017933 on Jan 24, 2012 5:49 AM
No, you can't use any 64bit software even your Mac is 64bit.
Oracle Instant Client should be 32bit, Python should be 32bit (export VERSIONER_PYTHON_PREFER_32_BIT=yes)