2

I receive the following error when trying to install cx_Oracle on Mac.

creating build/lib.macosx-10.10-intel-2.7-11g

c -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.10-intel-2.7-11g/cx_Oracle.o -L/Applications/oracle/product/instantclient_64/11.2.0.4.0/lib -lclntsh -o build/lib.macosx-10.10-intel-2.7-11g/cx_Oracle.so -shared-libgcc

ld: library not found for -lclntsh
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: command 'cc' failed with exit status 1

Appreciate any help on this. I have tried the solution under cx_oracle OSX install error thread, but still doesn't work.

Community
  • 1
  • 1
KunalBhai
  • 41
  • 5
  • @KunalBhai--are you using pip? How are you trying to install it? What version of OS X are you running? Are you using Homebrew? – inbinder Oct 27 '15 at 22:31
  • Yes I am using pip, I am on OSX Yosemite 10.10.5 (14F27) version, I have homebrew installed as well, I have the Instant client and sqlplus installed under /Applications/oracle folder. – KunalBhai Oct 28 '15 at 00:11

1 Answers1

3

Getting this to work is like getting dental work done, but there is light at the end of the tunnel. I'm assuming you've got Homebrew installed.

1) Download the following files from Oracle instantclient-basic-$VERSION-macosx-x64.zip instantclient-sdk-$VERSION-macosx-x64.zip

2) Create a directory mkdir /usr/lib/share/oracle

export ORACLE_HOME=/usr/lib/share/oracle
export VERSION=11.2.0.3.0
export ARCH=x86_64

mkdir -p $ORACLE_HOME

3) Unpack it

cd $ORACLE_HOME
tar -xzf instantclient-basic-$VERSION-macosx-x64.zip
tar -xzf instantclient-sdk-$VERSION-macosx-x64.zip

ln -s libclntsh.dylib.11.2 libclntsh.dylib
ln -s libocci.dylib.11.2 libocci.dylib

export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME

4) If you still have problems build from the source. 5) If you are still having problems try the 32bit version. 6) You may need to do some linking. Go back to build the 64bit from source and

ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib

I got this to work on Mavericks and on Yosemite.

inbinder
  • 692
  • 4
  • 11
  • 28
  • Hello, I am running OSX Yosemite and Python native build for Mac Python 2.7.6 . I have installed the 64 bit Instant client and sqlplus on to the system and works fine.I have installed the oracle client in a slightly different location than what you have given here. Where do I have to run this ln command ? – KunalBhai Oct 28 '15 at 02:39
  • ok so I tried the the export VERSION and export ARCH options that you had given and it worked ! I could successfully install cx_Oracle and ran python and it successfully imported the library ! thanks so much for your help. – KunalBhai Oct 28 '15 at 03:06
  • @KunalBhai--glad it worked out. Please up vote my answer . – inbinder Oct 28 '15 at 03:41