473,320 Members | 2,071 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.

example code to access some C++ classes in a DLL

Hi,

i have written a DLL that implements some C++ classes and
their methods. Now i would like to make the classes and
their methods known to python.

Is there some example code available on how to do this?
I want to make some classes, their constructors and some
methods known to python.

I've read the python docu "Tutorial", "Distributing Python Modules",
"Extending and Embedding" and "Python/X API".
But none of them seems to tell me how i can interface to:
namespace abc {
class Abc {
Abc();
~Abc();

int meth1(int abd, std::string s);
};

class Def {
Def();
~Def();

int meth1(long abd, char* g);
}
}

Has anybody got some example code for the necessary wrapper to make
all the above known to python?
Thanks for any hints,
Torsten.
Jul 18 '05 #1
1 3044
You can interface Python to ANY .DLL by using
CALLDLL. I've written a wrapper that I feel makes
doing this easier that is posted at:

http://aspn.activestate.com/ASPN/Coo.../Recipe/146847

-Larry

"Torsten Mohr" <tm***@s.netic.de> wrote in message
news:c1**********@schleim.qwe.de...
Hi,

i have written a DLL that implements some C++ classes and
their methods. Now i would like to make the classes and
their methods known to python.

Is there some example code available on how to do this?
I want to make some classes, their constructors and some
methods known to python.

I've read the python docu "Tutorial", "Distributing Python Modules",
"Extending and Embedding" and "Python/X API".
But none of them seems to tell me how i can interface to:
namespace abc {
class Abc {
Abc();
~Abc();

int meth1(int abd, std::string s);
};

class Def {
Def();
~Def();

int meth1(long abd, char* g);
}
}

Has anybody got some example code for the necessary wrapper to make
all the above known to python?
Thanks for any hints,
Torsten.

Jul 18 '05 #2

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

Similar topics

9
by: John Harrison | last post by:
Both gcc 3.3.1 and VC++ 7.1 compile the following code. struct Outer { struct Inner { int f() { return c; } }; private: static const int c;
45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
13
by: KV | last post by:
I'm new to OO Design, and I'm fixing to start writing my very first C# program. Given the complexity of OO programming, I would like to run something by this group and get general input. My...
1
by: Anonymous via the Cypherpunks Tonga Remailer | last post by:
Hi, I'm building a simple Object Oriented CMS using PHP5 and the new object model (new to both). I'm looking for some design advice on how best to integrate the database class - which creates...
10
by: Noozer | last post by:
I'm writing an ASP application and have a noob question... I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects...
4
by: Robert Schneider | last post by:
Hi, the msdn documentation provides an Dinosaurs example that uses the objectmodel.collection class. Just have a look on the help page for this class. I don't understand what happens here. Or...
7
by: eric | last post by:
hello i'm confused by an example in the book "Effective C++ Third Edition" and would be grateful for some help. here's the code: class Person { public: Person(); virtual ~Person(); // see...
4
by: CoreyWhite | last post by:
/* WORKING WITH STRINGS IN C++ IS THE BEST WAY TO LEARN THE LANGUAGE AND TRANSITION FROM C. C++ HAS MANY NEW FEATURES THAT WORK TOGETHER AND WHEN YOU SEE THEM DOING THE IMPOSSIBLE AND MAKING...
5
by: Gav | last post by:
I'm writing a windows application (using C# VS 2005 Pro) to access a MS SQL database and although it is working fine (up to now) I'm not sure I'm going about it in the best way. Can anybody point...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.