473,320 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ctypes: loading .so file on Linux

Hi,
I am am falling at the first hurdle when trying to access a library
using ctypes.

I have a file libucdb.so which the file command says is shared object,
but I cannot get it to load:

Any help would be appreciated:

dmccarthy: file /opt/questasim_6.4/questasim/linux/libucdb.a /opt/
questasim_=
6.4/questasim/linux/libucdb.so
/opt/questasim_6.4/questasim/linux/libucdb.a: current ar archive
/opt/questasim_6.4/questasim/linux/libucdb.so: ELF 32-bit LSB shared
object,=
Intel 80386, version 1 (SYSV), not stripped
dmccarthy: python
ActivePython 2.5.1.1 (ActiveState Software Inc.) based on
Python 2.5.1 (r251:54863, May 2 2007, 08:46:07)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>cdll.LoadLibrary("libc.so.6")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cdll' is not defined
>>from ctypes import *
^[[A^[[A
^e "<stdin>", line 1
SyntaxError: invalid syntax
>>cdll.LoadLibrary("libc.so.6")
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>
>>cdll.LoadLibrary("libucdb.so")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 423, in LoadLibrary
return self._dlltype(name)
File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry
>>cdll.LoadLibrary("libc.so.6")
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95df3ad0>
>>libc =3D CDLL("libc.so.6")
libc
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>
>>libc =3D CDLL("libucdb.so")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry
>>libc =3D CDLL("/opt/questasim_6.4/questasim/linux/libucdb.so")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
self._handle =3D _dlopen(self._name, mode)
OSError: /opt/questasim_6.4/questasim/linux/libucdb.so: cannot open
shared o=
bject file: No such file or directory
>>^[[A
File "<stdin>", line 1
^
SyntaxError: invalid syntax
>>>
- Paddy.
Aug 23 '08 #1
3 11136
On Aug 23, 2:33*pm, Paddy <paddy3...@googlemail.comwrote:
Hi,
I am am falling at the first hurdle when trying to access a library
using ctypes.

I have a file libucdb.so which the file command says is shared object,
but I cannot get it to load:

Any help would be appreciated:

dmccarthy: file /opt/questasim_6.4/questasim/linux/libucdb.a /opt/
questasim_=
6.4/questasim/linux/libucdb.so
/opt/questasim_6.4/questasim/linux/libucdb.a: *current ar archive
/opt/questasim_6.4/questasim/linux/libucdb.so: ELF 32-bit LSB shared
object,=
*Intel 80386, version 1 (SYSV), not stripped
dmccarthy: python
ActivePython 2.5.1.1 (ActiveState Software Inc.) based on
Python 2.5.1 (r251:54863, May *2 2007, 08:46:07)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>>cdll.LoadLibrary("libc.so.6")

Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
NameError: name 'cdll' is not defined>>from ctypes import *
>^[[A^[[A

* * ^e "<stdin>", line 1
SyntaxError: invalid syntax>>cdll.LoadLibrary("libc.so.6")

<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>>>cdll.LoadLibrary("libucdb.so")

Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 423, in LoadLibrary
* * return self._dlltype(name)
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry>>cdll.LoadLibrary("libc.so.6")

<CDLL 'libc.so.6', handle 2a958a2900 at 2a95df3ad0>>>libc =3D CDLL("libc.so.6")
>libc

<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>>>libc =3D CDLL("libucdb.so")

Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry>>libc =3D CDLL("/opt/questasim_6.4/questasim/linux/libucdb.so")

Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: /opt/questasim_6.4/questasim/linux/libucdb.so: cannot open
shared o=
bject file: No such file or directory>>^[[A

* File "<stdin>", line 1
* * ^
SyntaxError: invalid syntax

- Paddy.
Any help would be appreciated.

Thanks.
Aug 27 '08 #2
On Aug 27, 12:03*am, Paddy <paddy3...@googlemail.comwrote:
On Aug 23, 2:33*pm, Paddy <paddy3...@googlemail.comwrote:
Hi,
I am am falling at the first hurdle when trying to access a library
using ctypes.
I have a file libucdb.so which the file command says is shared object,
but I cannot get it to load:
Any help would be appreciated:
dmccarthy: file /opt/questasim_6.4/questasim/linux/libucdb.a /opt/
questasim_=
6.4/questasim/linux/libucdb.so
/opt/questasim_6.4/questasim/linux/libucdb.a: *current ar archive
/opt/questasim_6.4/questasim/linux/libucdb.so: ELF 32-bit LSB shared
object,=
*Intel 80386, version 1 (SYSV), not stripped
dmccarthy: python
ActivePython 2.5.1.1 (ActiveState Software Inc.) based on
Python 2.5.1 (r251:54863, May *2 2007, 08:46:07)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>cdll.LoadLibrary("libc.so.6")
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
NameError: name 'cdll' is not defined>>from ctypes import *
>>^[[A^[[A
* * ^e "<stdin>", line 1
SyntaxError: invalid syntax>>cdll.LoadLibrary("libc.so.6")
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>>>cdll.LoadLibrary("libucdb.so")
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 423, in LoadLibrary
* * return self._dlltype(name)
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry>>cdll.LoadLibrary("libc.so.6")
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95df3ad0>>>libc =3D CDLL("libc.so.6")
>>libc
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>>>libc =3D CDLL("libucdb.so")
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry>>libc =3D CDLL("/opt/questasim_6.4/questasim/linux/libucdb.so")
Try 'open( "libucdb.so", "rb" )' to see if you're looking in the right
place.
Aug 27 '08 #3
On 27 Aug., 07:03, Paddy <paddy3...@googlemail.comwrote:
On Aug 23, 2:33*pm, Paddy <paddy3...@googlemail.comwrote:
Hi,
I am am falling at the first hurdle when trying to access a library
using ctypes.
I have a file libucdb.so which the file command says is shared object,
but I cannot get it to load:
Any help would be appreciated:
dmccarthy: file /opt/questasim_6.4/questasim/linux/libucdb.a /opt/
questasim_=
6.4/questasim/linux/libucdb.so
/opt/questasim_6.4/questasim/linux/libucdb.a: *current ar archive
/opt/questasim_6.4/questasim/linux/libucdb.so: ELF 32-bit LSB shared
object,=
*Intel 80386, version 1 (SYSV), not stripped
dmccarthy: python
ActivePython 2.5.1.1 (ActiveState Software Inc.) based on
Python 2.5.1 (r251:54863, May *2 2007, 08:46:07)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>cdll.LoadLibrary("libc.so.6")
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
NameError: name 'cdll' is not defined>>from ctypes import *
>>^[[A^[[A
* * ^e "<stdin>", line 1
SyntaxError: invalid syntax>>cdll.LoadLibrary("libc.so.6")
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>>>cdll.LoadLibrary("libucdb.so")
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 423, in LoadLibrary
* * return self._dlltype(name)
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry>>cdll.LoadLibrary("libc.so.6")
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95df3ad0>>>libc =3D CDLL("libc.so.6")
>>libc
<CDLL 'libc.so.6', handle 2a958a2900 at 2a95dda490>>>libc =3D CDLL("libucdb.so")
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: libucdb.so: cannot open shared object file: No such file or
directo=
ry>>libc =3D CDLL("/opt/questasim_6.4/questasim/linux/libucdb.so")
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
* File "/software/unix-soft/linux/ActivePython-2.5.1.1-linux-x86_64/
lib/pyth=
on2.5/ctypes/__init__.py", line 340, in __init__
* * self._handle =3D _dlopen(self._name, mode)
OSError: /opt/questasim_6.4/questasim/linux/libucdb.so: cannot open
shared o=
bject file: No such file or directory>>^[[A
* File "<stdin>", line 1
* * ^
SyntaxError: invalid syntax
- Paddy.

Any help would be appreciated.

Thanks.
What is your current working directory and where is the lib located ?
Maybe the lib is not in your working directory.

If you want the lib accessed from anywhere, you have to copy it
to /usr/lib or /usr/local/lib.
Another possibility is setting LD_LIBRARY_PATH.

Greetings, Uwe
Aug 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
1
by: Thomas Heller | last post by:
ctypes 0.9.1 released - Sept 14, 2004 ===================================== Overview ctypes is a ffi (Foreign Function Interface) package for Python 2.3 and higher. ctypes allows to call...
19
by: Thomas Heller | last post by:
ctypes 0.9.2 released - Oct 28, 2004 ==================================== Overview ctypes is a ffi (Foreign Function Interface) package for Python 2.3 and higher. ctypes allows to call...
0
by: follower | last post by:
This post is mostly Google-bait for anyone else that might want to compile SpiderMonkey ( libjs / libjs.so / libjs.dylib ) for OS X (10.4.5 in my case) and then use it with Python's ctypes. I can't...
9
by: jtravs | last post by:
Hi all, I suspect that I'm doing something stupid, I would like some other opinions though. I'm getting started with ctypes and am trying to use distutils to help build my module. At the moment...
5
by: SoutoJohn | last post by:
I'm trying to install PyWinAuto for Python 2.4. It said that one of the required libraries that I need to install would be CTypes. So I head over to CTypes's SourceForge page and I installed CTypes...
0
by: Jorge Vargas | last post by:
Hi I'm having an issue with ctypes loading libraries. I got the following setup. I have a library (coded by me) that calls a external library (installed with the package manager), and my...
0
by: Martin (gzlist) | last post by:
On 26/08/2008, Tim Grove <tim_grove@sil.orgwrote: I'm going to take a stab in the dark here and suggest it's because you have multiple (different) copies of iconv.dll on your PATH. I get...
0
by: Tim Grove | last post by:
Thanks for your advice Gerdus, but I have tried your suggestion with no success. It has at least been beneficial to discover a tool which I did not know about in 'Dependency Walker'; all...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.