Hy,
I need help about use dll with ctypes. I've compiled my dll C library
and I copied it in c:\windows\system32. When I load it with
"myDLL=cdll.LoadLibrary(find_library("myDLL.dll")) " It seem all OK but
python don't see the dll function. with dir(myDLL) I've only this:
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__getattr__', '__getattribute__', '__getitem__', '__hash__',
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', '__weakref__', '_handle',
'_name']
Could anybody help me
Thanks
Gianluca 8 4659
On May 23, 12:33 am, gianluca <geonom...@gmail.comwrote:
Hy,
I need help about use dll with ctypes. I've compiled my dll C library
and I copied it in c:\windows\system32. When I load it with
"myDLL=cdll.LoadLibrary(find_library("myDLL.dll")) " It seem all OK but
python don't see the dll function. with dir(myDLL) I've only this:
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__getattr__', '__getattribute__', '__getitem__', '__hash__',
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', '__weakref__', '_handle',
'_name']
I see nothing wrong here.
gianluca wrote:
Hy,
I need help about use dll with ctypes. I've compiled my dll C library
and I copied it in c:\windows\system32. When I load it with
"myDLL=cdll.LoadLibrary(find_library("myDLL.dll")) " It seem all OK but
python don't see the dll function. with dir(myDLL) I've only this:
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__getattr__', '__getattribute__', '__getitem__', '__hash__',
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', '__weakref__', '_handle',
'_name']
Could anybody help me
Thanks
Gianluca
Since it isn't python, dir can'd do much introspection on the object to produce
the type of output you desire. You have to know the functions (methods) that
you want to call in your dll and call them.
-Larry Bates
On 23 Mag, 01:14, Larry Bates <larry.ba...@websafe.com`wrote:
gianluca wrote:
Hy,
I need help about use dll with ctypes. I've compiled my dll C library
and I copied it in c:\windows\system32. When I load it with
"myDLL=cdll.LoadLibrary(find_library("myDLL.dll")) " It seem all OK but
python don't see the dll function. with dir(myDLL) I've only this:
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__getattr__', '__getattribute__', '__getitem__', '__hash__',
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', '__weakref__', '_handle',
'_name']
Could anybody help me
Thanks
Gianluca
Since it isn't python, dir can'd do much introspection on the object to produce
the type of output you desire. You have to know the functions (methods) that
you want to call in your dll and call them.
-Larry Bates
Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an
exception like this:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
myDLL.myFUNCT()
File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__
func = self.__getitem__(name)
File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'myFUNCT' not found
Thanks for help
On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote:
Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an
exception like this:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
myDLL.myFUNCT()
File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__
func = self.__getitem__(name)
File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'myFUNCT' not found
Then maybe the DLL doesn't contain a function called `myFUNCT`. Any
chance you compiled your C as C++ and name mangling kicked in?
Can you show a minimal C source for a DLL, how you compiled it, what you
did on the Python side to call it, and how it fails?
Ciao,
Marc 'BlackJack' Rintsch
On 23 Mag, 07:48, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote:
Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an
exception like this:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
myDLL.myFUNCT()
File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__
func = self.__getitem__(name)
File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'myFUNCT' not found
Then maybe the DLL doesn't contain a function called `myFUNCT`. Any
chance you compiled your C as C++ and name mangling kicked in?
Can you show a minimal C source for a DLL, how you compiled it, what you
did on the Python side to call it, and how it fails?
Ciao,
Marc 'BlackJack' Rintsch
I've located my dll in c:\windows\system32 (in linux I aven't any
problem) and I compiled it with dev-c++. The source code is C standard
ANSII and is quite havy. If you like I can send it via mail (you can
realy at ge*******@gmail.com) . I've tryed to build a wrape with swig
olso with same code and I can access at all the function.
thanks
Gianluca
gianluca <ge*******@gmail.comwrote:
On 23 Mag, 07:48, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote:
Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an
exception like this:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
myDLL.myFUNCT()
File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__
func = self.__getitem__(name)
File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'myFUNCT' not found
Then maybe the DLL doesn't contain a function called `myFUNCT`. Any
chance you compiled your C as C++ and name mangling kicked in?
Can you show a minimal C source for a DLL, how you compiled it, what you
did on the Python side to call it, and how it fails?
Ciao,
Marc 'BlackJack' Rintsch
I've located my dll in c:\windows\system32 (in linux I aven't any
problem) and I compiled it with dev-c++. The source code is C standard
ANSII and is quite havy. If you like I can send it via mail (you can
realy at ge*******@gmail.com) . I've tryed to build a wrape with swig
olso with same code and I can access at all the function.
You can use objdump from mingw or cygwin to look inside the dll and
see exactly what it is exporting, eg
objdump -x OurSharedCodeLibrary.dll
This prints a great deal of stuff! In the middle you'll see
[snip]
The Export Tables (interpreted .rdata section contents)
[snip]
Ordinal/Name Pointer] Table
[ 0] OSCL_DEBUG_fakeInitComplete
[ 1] OSCL_close
[ 2] OSCL_displayIdent
[ 3] OSCL_getCurrentDynamicParams
[ 4] OSCL_getCurrentStaticParams
[ 5] OSCL_getErrorString
[ 6] OSCL_getIdent
[snip]
This is a dll we used in a project, and those names exactly worked
with ctypes, eg some snips from the ctypes code
self.dll = cdll.LoadLibrary("OurSharedCodeLibrary")
self.dll.OSCL_getErrorString.restype = c_char_p
def getErrorString(self, status):
return self.dll.OSCL_getErrorString(c_int(status))
--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
On 23 Mag, 12:30, Nick Craig-Wood <n...@craig-wood.comwrote:
gianluca <geonom...@gmail.comwrote:
On 23 Mag, 07:48, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote:
Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an
exception like this:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
myDLL.myFUNCT()
File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__
func = self.__getitem__(name)
File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'myFUNCT' not found
Then maybe the DLL doesn't contain a function called `myFUNCT`. Any
chance you compiled your C as C++ and name mangling kicked in?
Can you show a minimal C source for a DLL, how you compiled it, what you
did on the Python side to call it, and how it fails?
Ciao,
Marc 'BlackJack' Rintsch
I've located my dll in c:\windows\system32 (in linux I aven't any
problem) and I compiled it with dev-c++. The source code is C standard
ANSII and is quite havy. If you like I can send it via mail (you can
realy at geonom...@gmail.com) . I've tryed to build a wrape with swig
olso with same code and I can access at all the function.
You can use objdump from mingw or cygwin to look inside the dll and
see exactly what it is exporting, eg
objdump -x OurSharedCodeLibrary.dll
This prints a great deal of stuff! In the middle you'll see
[snip]
The Export Tables (interpreted .rdata section contents)
[snip]
Ordinal/Name Pointer] Table
[ 0] OSCL_DEBUG_fakeInitComplete
[ 1] OSCL_close
[ 2] OSCL_displayIdent
[ 3] OSCL_getCurrentDynamicParams
[ 4] OSCL_getCurrentStaticParams
[ 5] OSCL_getErrorString
[ 6] OSCL_getIdent
[snip]
This is a dll we used in a project, and those names exactly worked
with ctypes, eg some snips from the ctypes code
self.dll = cdll.LoadLibrary("OurSharedCodeLibrary")
self.dll.OSCL_getErrorString.restype = c_char_p
def getErrorString(self, status):
return self.dll.OSCL_getErrorString(c_int(status))
--
Nick Craig-Wood <n...@craig-wood.com--http://www.craig-wood.com/nick
Thank you for help!
I've done all you suggest and I've a objdump output like this:
....
[ 86](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00003755 _IsCoverRelD
[ 87](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00003657 _IsCoverRelA
[ 88](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x000034f5 _IsCoverDX
[ 89](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x0000341b _IsCoverA
[ 90](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00003072 _CoreRelD
[ 91](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00002f5e _CoreRelA
....
my funtions are the __IsCoverRelD, __IsCoverRelA, etc but when I call
it (myLIB.__IsCoverRelA or myLIB.__IsCoverRelA()) I've the same
problem.
Hy
gianluca
"gianluca" <ge*******@gmail.comwrote in message
news:ce**********************************@e39g2000 hsf.googlegroups.com...
| Thank you for help!
| I've done all you suggest and I've a objdump output like this:
| ...
| [ 86](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00003755 _IsCoverRelD
| [ 87](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00003657 _IsCoverRelA
| [ 88](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x000034f5 _IsCoverDX
| [ 89](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x0000341b _IsCoverA
| [ 90](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00003072 _CoreRelD
| [ 91](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00002f5e _CoreRelA
The name above have one underscore.
| my funtions are the __IsCoverRelD, __IsCoverRelA, etc but when I call
| it (myLIB.__IsCoverRelA or myLIB.__IsCoverRelA()) I've the same
| problem.
These all have two. So if that is what you actually did....
tjr This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: achrist |
last post by:
I'm aving some trouble getting callbacks from a Delphi DLL back to
python working through ctypes.
The call from python to the DLL works fine.
In the Delphi(5) code:
type
TCallbackFunc =...
|
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...
|
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...
|
by: gap |
last post by:
I'm no c programmer, and I'm a ctypes newbie. I'll frame my problem as
simply as I can. Sorry if it's too much or not enough info. I don't
expect an explicit answer (but maybe), just help...
|
by: sjdevnull |
last post by:
Hey,
I'm trying to wrap GNU readline with ctypes (the Python readline
library doesn't support the callback interface), but I can't figure out
how to set values to a variable inside the library. ...
|
by: malen |
last post by:
Hi all!
I'm building mouse movement filter program for Windows and Mac OS X. In Windows I use ctypes.windll.user32.getCursorPos(pointer) and ctypes.windll.user32.setCursorPos(x,y) to get and set...
|
by: moreati |
last post by:
Recently I discovered the re module doesn't support POSIX character
classes:
Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
on linux2
Type "help", "copyright", "credits" or "license" for...
|
by: Egor Zindy |
last post by:
Egor Zindy wrote:
#!/usr/bin/env python
"""
A generic chipid library based on ctypes
This module handles most of the functions in FTChipID.dll
|
by: Paddy |
last post by:
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...
|
by: Sells, Fred |
last post by:
Diez wrote...
You're right the ctypes does seem more pythonesque; however I'm still stuck trying return all these parameters
that the c api uses. my ctypes code is below. It just quits running...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
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...
|
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...
|
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...
| |