PHP 5.4 compilation with PDO-OCI driver using Oracle Instant client 10.2.0.4

12.8k views Asked by At

I have downloaded Instant client 10.2.0.4 basic and sdk zip files from Instant Client downloads for Mac OS X (Intel x86),

I extracted into a folder as shown below

-rw-r--r--@ 1 MNV_Kishore  1000     278 Apr  1  2009 BASIC_README
-r--r--r--@ 1 MNV_Kishore  1000 1609607 Feb  2  2008 classes12.jar
-rwxr-xr-x@ 1 MNV_Kishore  1000     34168 Apr  1  2009 genezi
lrwxr-xr-x  1 MNV_Kishore  wheel        20 Dec  2 18:10 libclntsh.dylib -> libclntsh.dylib.10.1

-rwxr-xr-x@ 1 MNV_Kishore  1000   25582048 Mar 31  2009 libclntsh.dylib.10.1
-rwxr-xr-x@ 1 MNV_Kishore  1000 2062528 Mar  3  2009 libnnz10.dylib
lrwxr-xr-x  1 MNV_Kishore  wheel        18 Dec  2 18:10 libocci.dylib -> libocci.dylib.10.1
-rwxr-xr-x@ 1 MNV_Kishore  1000 1277896 Mar  3  2009 libocci.dylib.10.1

-rwxr-xr-x@ 1 MNV_Kishore  1000   72626768 Apr  1  2009 libociei.dylib
-rwxr-xr-x@ 1 MNV_Kishore  1000     118672 Mar 25  2009 libocijdbc10.dylib
-rwxr-xr-x@ 1 MNV_Kishore  1000     118672 Mar 25  2009 libocijdbc10.jnilib
-r--r--r--@ 1 MNV_Kishore  1000 1555682 Feb  2  2008 ojdbc14.jar
drwxr-xr-x@ 7 MNV_Kishore  wheel    238 Apr  1  2009 sdk

All header files .h are present in include dir under sdk

When I tried to configure with command as...

./configure --with-pdo-oci=instantclient,/usr/local/instantclient_10_2,10.2.0.4

... the below error is encountered

checking for oci.h... configure: error: I'm too dumb to figure out where the include dir is in your instant client install

Could any one please help me with this error?

4

There are 4 answers

1
Eric On

We recently had to install this on a CentOS box, so the paths might be a little different. Also, we used a pre-compiled PHP instance, and added the OCI8 functions as a separate module. Before using CentoOS, we installed to our Mac workstations using these instructions (they are a bit dated, so I don't know if this will still work with current versions of OS X and PHP): http://articles.serenity.de/compiling_php_with_oracle/

For our CentOS install, we had to do the following:

  • Install/compile PHP 5.4 without instant client support.

  • Get the instantClient basic and SDK packages and install them (looks like you already have both).

  • When the OCI configure scirpt claims that it is too dumb to find the headers, it's not being sarcastic, so you have tot set up a rat's nest of symlinks. On CentOS, the basic client is installed in /usr/lib/oracle/10.2.0.3/client64, and the SDK files are in /usr/include/oracle/10.2.0.3/client64/.

cd /usr/lib/oracle/10.2.0.3/client64
cp /usr/include/oracle/10.2.0.3/client64/* .
ln -s lib/libnnz10.so libnnz.so
ln -s lib/libclntsh.so.10.1 libclntsh.so
ln -s lib/libnnz10.so libnnz10.so
ln -s lib/libclntsh.so.10.1 libclntsh.so.10.1
  • Now you can install OCI8 from pecl. Note that at this point PDO_OCI will not work. This is ONLY for the OCI8 driver:

pecl install oci8

  • For PDO_OCI support you will also need to add some more symlinks:
cd /usr/lib/oracle/10.2.0.3/client64
mkdir sdk
cd sdk && ln -s /usr/include/oracle/10.2.0.3/client64 include
ln -s /usr/lib/oracle/10.2.0.3/client64/sdk/include/ /usr/lib/oracle/10.2.0.3/client/include
ln -s /usr/lib/oracle/10.2.0.3/client64/ /usr/lib/oracle/10.2.0.3/client
ln -s /usr/include/oracle/10.2.0.3/client64/ /usr/include/oracle/10.2.0.3/client
  • PDO OCI has been not been maintained for several years, so it won't install directly from pecl. Instead, you will have to download it and make some changes. The sed command updates function_entry to zend_function_entry so that it will compile properly:
pecl download pdo_oci
tar -xvf PDO_OCI-1.0.tgz
cd PDO_OCI-1.0
sed -i -e 's/function_entry pdo_oci_functions/zend_function_entry pdo_oci_functions/' pdo_oci.c
mkdir include
ln -s /usr/include/php include/php
phpize
cp /usr/include/oracle/10.2.0.3/client64/* ./include
./configure --with-pdo-oci=instantclient,/usr,10.2.0.3
make && make install

At this point PDO_OCI should work with your PHP install. If you are still having trouble, you can look in the configure and make scirpts to see which dircotories and symlinks are expected for your system. Brad was speaking literally when he said that this took days to figure out. Hopefully it will help you get it working much faster.

0
Kishore On

I have been able to install the PDO_OCI module with the following changes (may not be the most perfect soln, but got it working)..

i) Installed InstantClient and SDK modules in a specific folder structure, by reviewing config script /usr/lib/oracle//client/ You could also have the instantclient extracted into a similar structure under usr/include..

ii) Modified config.m4 script to replace function_entry with zend_function_entry

iii) Placed all header files in an include dir of oracle home directory

iv) Created symlinks for *.dylib. modules to *.dylib For ex: ln -s libclntsh.dylib.10.1 to libclntsh.dylib Please note that the version present in library files should be same as folder to be created

All this was found by reviewing the config.m4 script of PDO_OCI extract

0
SSS B On

Even though ORACLE_HOME was set properly i used to get this error so gave export before running configure in PDO_OCI-1.0 direcory

export ORACLE_HOME=/opt/instantclient_10_2/

1
nhereveri On

Maybe it is just an autoconf issue. I compile the last one from source and works perfectly. I create a post just to explain the right procedure.