[egenix-users] Non-standard location for iODBC, libiodbc.so.2 notfound

Charles Bearden Charles.F.Bearden at uth.tmc.edu
Wed Aug 18 17:32:11 CEST 2004


> -----Original Message-----
> From: egenix-users-bounces at lists.egenix.com [mailto:egenix-users-
> bounces at lists.egenix.com] On Behalf Of Joseph Kocherhans
> Sent: Wednesday, August 18, 2004 4:23 PM
> To: egenix-users at lists.egenix.com
> Subject: [egenix-users] Non-standard location for iODBC, libiodbc.so.2
> notfound
> 
> I've been having trouble with the packaged versions of iodbc and
> freetds on debian, so I decided to try building them both from source.
> I put iodbc in /opt/iodbc, and tested the freetds odbc driver with
> iodbctest. Everything looks good. I modified mxCOMMERCIAL.py to:
> 
>          Extension('mx.ODBC.iODBC.mxODBC',
>                    ['mx/ODBC/iODBC/mxODBC.c',
>                     'mx/ODBC/iODBC/mxSQLCodes.c'
>                     ],
>                    include_dirs=['mx/ODBC/iODBC',
>                                  '/opt/iodbc/include'],
>                    define_macros=[('iODBC', None),
>                                   ('MAX_COLUMN_NAME_LENGTH', '50')],
>                    library_dirs=['/opt/iodbc/lib'],
>                    libraries=['iodbc']
>                    ),
> 
> Everything builds fine, (running "python2.3 setup.py install") but
when
> I try to import mx.ODBC.iODBC in python2.3, I get the following error:
> 
> Traceback (most recent call last):
>    File "/home/jkocherhans/mxodbctest.py", line 1, in ?
>      from mx.ODBC.iODBC import DriverConnect
>    File "/usr/lib/python2.3/site-packages/mx/ODBC/iODBC/__init__.py",
> line 8, in ?
>      from mxODBC import *
> ImportError: libiodbc.so.2: cannot open shared object file: No such
> file or directory
> 
> Is there something besides include_dirs and library_dirs I need to
> change to use the iODBC I installed in /opt?

Hi Joseph,

Even though you tell mxCOMMERCIAL.py where to find the iODBC libraries
when building, the system won't know where they are when running
applications.  You need to do one of two things:

1) set the LD_LIBRARY_PATH environment variable to include
'/opt/iodbc/lib' in each session that expects to use mx.ODBC.iODBC; or 

2) add '/opt/iodbc/lib' to the list of library paths in /etc/ld.so.conf,
and than run ldconfig to update the system-wide cache of library links.
You can run it with the '-v' flag and pipe through less to see the
directories it processes.

The second solution is usually better because it is more transparent to
users, but you do need to be root to update the system-wide
/etc/ld.so.cache.  The first solution is simple to implement via the
Python os.environ dictionary of environment variables, but it must be
done in every script that needs to load shared libraries from unorthodox
locations.  If you are installing to /opt, I'll bet you have permissions
to run ldconfig.

Hope that helps out.

Chuck Bearden
Systems Analyst III
School of Health Information Sciences
University of Texas at Houston
713.500.3954 (voice)
713.500.3907 (fax)
Charles.F.Bearden at uth.tmc.edu



More information about the egenix-users mailing list