在HP-UX下编译Python和cx_Oracle

在HP-UX下编译Python和cx_Oracle(转)
===========================================================
作者: rainrhb(http://rainrhb.itpub.net)
发表于: 2006.08.22 22:17
分类: Oracle
出处: http://rainrhb.itpub.net/post/21031/197395
---------------------------------------------------------------
最近在HP-UX下用HP ANSI C编译了Python 2.4.3和cx_Oracle-4.2。
在import cx_Oracle的时候出现错误。
在HP-UX下编译Python和cx_Oracle 最近在HP-UX下用HP ANSI C编译了Python 2.4.3和cx_Oracle-4.2。在import cx_Oracle的时候出现

Python 2.4.3 (#3, Aug 22 2006, 19:21:46) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /usr/lib/libcl.2
/usr/lib/dld.sl: Exec format error
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: Failed to load /home/freider/local/lib/python2.4/site-packages/cx_Oracle.sl

%ldd build/lib.hp-ux-B.11.11-9000/800-2.4/cx_Oracle.sl
        /oracle/product/10.1.0.2/lib32/libclntsh.sl.10.1 => /oracle/product/10.1.0.2/lib32/libclntsh.sl.10.1
        /usr/lib/libcl.2 =>     /usr/lib/libcl.2
        /usr/lib/libisamstub.1 =>       /usr/lib/libisamstub.1
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libm.2 =>      /usr/lib/libm.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libnss_dns.1 =>        /usr/lib/libnss_dns.1
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libpthread.1 =>        /usr/lib/libpthread.1
        /usr/lib/librt.2 =>     /usr/lib/librt.2
        /oracle/product/10.1.0.2/lib32/libnnz10.sl =>   /oracle/product/10.1.0.2/lib32/libnnz10.sl

网络上大部分方法是用gcc3.x编译。经过多日摸索,用HP ANSI C编译的方法如下。
方法1. 设置环境变量LD_PRELOAD。

setenv LD_PRELOAD /usr/lib/libcl.2
python
import cx_Oracle

方法2. 静态连接libcl.sl (-lcl)

setenv ORACLE_HOME /oracle/product/10.1.0.2
setenv LDFLAGS '-lcl'

重新编译python

用下面的方法重新编译 cx_Oracle

modify setyp.py from
libPath = os.path.join(oracleHome, "lib")
to
libPath = os.path.join(oracleHome, "lib32")

python setyp.py build
python setyp.py install


% ldd build/lib.hp-ux-B.11.11-9000/800-2.4/cx_Oracle.sl
        /oracle/product/10.1.0.2/lib32/libclntsh.sl.10.1 => /oracle/product/10.1.0.2/lib32/libclntsh.sl.10.1
        /usr/lib/libcl.2 =>     /usr/lib/libcl.2
        /usr/lib/libisamstub.1 =>       /usr/lib/libisamstub.1
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libm.2 =>      /usr/lib/libm.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libnss_dns.1 =>        /usr/lib/libnss_dns.1
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libpthread.1 =>        /usr/lib/libpthread.1
        /usr/lib/librt.2 =>     /usr/lib/librt.2
        /oracle/product/10.1.0.2/lib32/libnnz10.sl =>   /oracle/product/10.1.0.2/lib32/libnnz10.sl
        /usr/lib/libcl.2 =>     /usr/lib/libcl.2

你可能感兴趣的:(oracle,c,python,OS,HP)