{"id":52,"date":"2005-09-27T10:53:18","date_gmt":"2005-09-27T09:53:18","guid":{"rendered":"http:\/\/pgregg.com\/wp\/2005\/09\/compiling-php-oci8-on-sparc64-solaris-10-with-oracle10g\/"},"modified":"2005-09-27T10:53:18","modified_gmt":"2005-09-27T09:53:18","slug":"compiling-php-oci8-on-sparc64-solaris-10-with-oracle10g","status":"publish","type":"post","link":"https:\/\/blog.pgregg.com\/blog\/2005\/09\/compiling-php-oci8-on-sparc64-solaris-10-with-oracle10g\/","title":{"rendered":"Compiling PHP, OCI8 on Sparc64 Solaris 10 with Oracle10g"},"content":{"rendered":"<p>This problem beat me about the head for most of yesterday until I worked out that PHP 5.0.5 doesn&#8217;t actually know about Oracle 10.&nbsp; &nbsp; 8 and 9, sure thing &#8211; otherwise it decides it is an older version (very silly).<\/p>\n<p>The other problem is that when PHP tries to link to the oracle client libraries, by default it attempts to link against the 64 bit libraries &#8211; which with PHP being a 32bit app just isn&#8217;t going to fly.<\/p>\n<p>So here I will attempt to guide you in all that is good with PHP and Oracle 10.<\/p>\n<p>The first thing to do is ensure you have a working Solaris 10 install with Oracle 10g already<br \/>installed.&nbsp; &nbsp;As this was to be an actual server machine I installed the full database server including client libraries (which happens by default when you install server).&nbsp; However the purpose of this is not to help you install Oracle &#8211; there are plenty of guides out there for that.&nbsp; This is to help you get PHP compiled in this environment &#8211; there are no guides for that.<\/p>\n<p>So lets unpack the PHP source:<br \/>#-&gt;tar xf php-5.0.5.tar<br \/>#-&gt;cd php-5.0.5<br \/>php-5.0.5-#-&gt;<\/p>\n<p>Now, If you run a straight .\/configure &#8211;with-oci8 it will most likely fail being unable to find the oracle install:<br \/>checking Oracle version&#8230; configure: error: Oracle (OCI8) required libraries not found<\/p>\n<p>We need to tell it where to find the oracle libraries.<br \/>.\/configure &#8211;with-oci8=\/u01\/app\/oracle\/product\/10.2.0\/Db_1<br \/>(assuming this is where your default database was installed to)<\/p>\n<p>This will enable configure to complete.<\/p>\n<p>Next, naturally, we try to make php &#8211; all should go well right up until the final link:<br \/>php-5.0.5-#-&gt;make<br \/>&#8230; [snip] &#8230;<br \/>ld: fatal: file \/u01\/app\/oracle\/product\/10.2.0\/Db_1\/lib\/libclntsh.so: wrong ELF class: ELFCLASS64<br \/>ld: fatal: File processing errors. No output written to sapi\/cgi\/php<br \/>collect2: ld returned 1 exit status<br \/>make: *** [sapi\/cgi\/php] Error 1<\/p>\n<p>This fails because PHP has decided to link against lib\/libclntsh.so when it should have linked against lib32\/libclntsh.so<\/p>\n<p>No amount of adding &#8211;includedir= and &#8211;libdir= on the configure command will result in make doing the right thing and linking against the lib32 version.<\/p>\n<p>The solution? We need to edit the configure script to tell it that lib isn&#8217;t the be-all and end-all of oracle libraries.&nbsp; This is a pain, I know, but hopefully the PHP people will fix this for 5.0.6 and above.<\/p>\n<p>At line 64660 in configure you will see the line:<br \/>&nbsp; elif test -f $OCI8_DIR\/lib\/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then<\/p>\n<p>Change \/lib\/ to \/lib32\/<\/p>\n<p>And at line 69134 you&#8217;ll notice that it is missing any reference to Oracle 10.1, so we need to add it &#8211; add the following two lines just before the 9.0 line:<br \/>&nbsp; elif test -f $ORACLE_DIR\/lib32\/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then<br \/>&nbsp; &nbsp; ORACLE_VERSION=10.1<\/p>\n<p>At line 64977 change:<br \/>&nbsp; if test -z &quot;$OCI8_DIR\/lib&quot; || echo &quot;$OCI8_DIR\/lib&quot; | grep &#8216;^\/&#8217; &gt;\/dev\/null ; then<br \/>&nbsp; &nbsp; ai_p=$OCI8_DIR\/lib<br \/>to:<br \/>&nbsp; if test -z &quot;$OCI8_DIR\/lib32&quot; || echo &quot;$OCI8_DIR\/lib32&quot; | grep &#8216;^\/&#8217; &gt;\/dev\/null ; then<br \/>&nbsp; &nbsp; ai_p=$OCI8_DIR\/lib32<\/p>\n<p>Line 64368: add<br \/>&nbsp; OCI8_SHARED_LIBADD=&quot;-L$OCI8_DIR\/lib32&quot;<br \/>&nbsp; LIBS=&quot;$LIBS -L$OCI8_DIR\/lib32&quot;<\/p>\n<p>Now make clean;<br \/>cd to your database and rename the lib directory to lib.unused temporarily so that PHP cannot link against it and leave the lib32 one as is.<\/p>\n<p>Switch back to php dir. Run your configure command, make (which should now complete) and make install.<\/p>\n<p>Go back and rename the lib.unused back to lib as other things will need this to exist.<\/p>\n<p>Finally, make sure you add the lib32 path to your LD_LIBRARY_PATH variable before starting apache\/php<\/p>\n<p>LD_LIBRARY_PATH=&quot;$LD_LIBRARY_PATH:\/u01\/app\/oracle\/product\/10.2.0\/Db_1\/lib32&quot;<\/p>\n<p>Your PHP should now be working fine.<\/p>\n<p>Files to help: My &quot;configure&quot; command:<br \/>&#8216;.\/configure&#8217; <br \/>&#8216;&#8211;prefix=\/usr\/local\/apache2&#8217; <br \/>&#8216;&#8211;includedir=\/space\/app\/oracle\/product\/10.2.0\/Db_1\/rdbms\/public&#8217; <br \/>&#8216;&#8211;oldincludedir=\/space\/app\/oracle\/product\/10.2.0\/Db_1\/rdbms\/public&#8217; <br \/>&#8216;&#8211;libdir=\/space\/app\/oracle\/product\/10.2.0\/Db_1\/lib32&#8217; <br \/>&#8216;&#8211;with-apxs2=\/usr\/local\/apache2\/bin\/apxs&#8217; <br \/>&#8216;&#8211;with-oci8=\/u01\/app\/oracle\/product\/10.2.0\/Db_1&#8217;<\/p>\n<p>Diff of the configure script to the regular one supplied with PHP 5.0.5<br \/>#-&gt;diff php-5.0.5\/configure php-5.0.5-working\/configure&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6:39AM<br \/>64367a64368,64369<br \/>&gt;&nbsp; &nbsp;OCI8_SHARED_LIBADD=&quot;-L$OCI8_DIR\/lib32&quot;<br \/>&gt;&nbsp; &nbsp;LIBS=&quot;$LIBS -L$OCI8_DIR\/lib32&quot;<br \/>64660c64662<br \/>&lt;&nbsp; &nbsp;elif test -f $OCI8_DIR\/lib\/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then<br \/>&#8212;<br \/>&gt;&nbsp; &nbsp;elif test -f $OCI8_DIR\/lib32\/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then<br \/>64977,64978c64979,64980<br \/>&lt;&nbsp; &nbsp;if test -z &quot;$OCI8_DIR\/lib&quot; || echo &quot;$OCI8_DIR\/lib&quot; | grep &#8216;^\/&#8217; &gt;\/dev\/null ; then<br \/>&lt;&nbsp; &nbsp; &nbsp;ai_p=$OCI8_DIR\/lib<br \/>&#8212;<br \/>&gt;&nbsp; &nbsp;if test -z &quot;$OCI8_DIR\/lib32&quot; || echo &quot;$OCI8_DIR\/lib32&quot; | grep &#8216;^\/&#8217; &gt;\/dev\/null ; then<br \/>&gt;&nbsp; &nbsp; &nbsp;ai_p=$OCI8_DIR\/lib32<br \/>69133a69136,69137<br \/>&gt;&nbsp; &nbsp;elif test -f $ORACLE_DIR\/lib32\/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then<br \/>&gt;&nbsp; &nbsp; &nbsp;ORACLE_VERSION=10.1<\/p>\n<p>Note to PHP developers if they read this &#8211; this patch is not one that can be dropped into the regular build &#8211; it will only help people who have difficulty installing PHP with OCI8\/Oracle10 on Solaris10.<\/p>\n<p>I hope this proves useful to others &#8211; it took me &gt;24 hours work to get to this point.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This problem beat me about the head for most of yesterday until I worked out that PHP 5.0.5 doesn&#8217;t actually know about Oracle 10.&nbsp; &nbsp; 8 and 9, sure thing &#8211; otherwise it decides it is an older version (very silly). The other problem is that when PHP tries to link to the oracle client &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.pgregg.com\/blog\/2005\/09\/compiling-php-oci8-on-sparc64-solaris-10-with-oracle10g\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Compiling PHP, OCI8 on Sparc64 Solaris 10 with Oracle10g&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"1","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-php"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pbQOUu-Q","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":0,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}