By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,666 Members | 1,402 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,666 IT Pros & Developers. It's quick & easy.

how to export functions by name for ctype

P: n/a
I'm on Windows with VS2005 testing ctypes on a very simple dll
I create a test.dll project which exports a function fntest(). I don't
touch anything in the autogenerated source and build it. I can load
the dll but can't access the function by its name fntest. Only by
ordinal number or calling getattr with "?fntest@@YAHXZ". How do I
export functions by name? It's probably rather a VS2005 question, but
I'm a bit disappointed ctypes doesn't work with a default export
convention.
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies

P: n/a
rych <ry*****@gmail.comwrote:
I'm on Windows with VS2005 testing ctypes on a very simple dll
I create a test.dll project which exports a function fntest(). I don't
touch anything in the autogenerated source and build it. I can load
the dll but can't access the function by its name fntest. Only by
ordinal number or calling getattr with "?fntest@@YAHXZ". How do I
export functions by name? It's probably rather a VS2005 question, but
I'm a bit disappointed ctypes doesn't work with a default export
convention.
I guess you've compiled your DLL with C++ and the above is a C++
mangled name.

Either compile it with C, or export the names in an extern "C" { }
block.
--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jun 27 '08 #2

P: n/a
On 23 Jun, 10:32, Nick Craig-Wood <n...@craig-wood.comwrote:
rych <rych...@gmail.comwrote:
*I'm on Windows with VS2005 testing ctypes on a very simple dll
*I create a test.dll project which exports a function fntest(). I don't
*touch anything in the autogenerated source and build it. I can load
*the dll but can't access the function by its name fntest. Only by
*ordinal number or calling getattr with "?fntest@@YAHXZ". How do I
*export functions by name? It's probably rather a VS2005 question, but
*I'm a bit disappointed ctypes doesn't work with a default export
*convention.

I guess you've compiled your DLL with C++ and the above is a C++
mangled name.

Either compile it with C, or export the names in an extern "C" { }
block.

--
Nick Craig-Wood <n...@craig-wood.com--http://www.craig-wood.com/nick
That fixed it, thank you.
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.