Hello,

Private And Confidential wrote:
Hello,

I have a C++ library which implements about two dozen classes -- data structures and methods which manipulate them. I would like to write a perl module for the library with XS. I have seen a lot of examples of how to interface to C++ with XS and I've successfully built and tested an interface for one of the classes from the library. However I can not find a good (simple) example how to interface to one library which implements multiple independent classes ( i.e. DS::A, DS::B, and DS::C).

I was able to setup the build files so that I could put each class in a seperate XS file and have it build "correctly" however the module required a copy of the .o for each class.

I think what I would like to setup is a base class (i.e. DS) that will link to the C++ library and export every "DS" class whenever any class in the module is referenced. I would like to keep each class in a seperate XS file for manageability -- unless there is a better method.

If someone could show me a basic example of how to do something like this, I would really appreciate it.


You can write as many *.cpp/*.hpp/*.h files as you want in the module directory. In the XS file you only have to include the *.hpp files. And than you can use in the makefile.pl the parameter 'OBJECT'=> '$(O_FILES)', which links all *.o (or on win *.obj) into one dll which can be used. My module Win32-File-Summary, I think is similar to that what you want. The OOo.cpp contain the code, the OOo.h contain the class definition class OOo. Take also a look into the Summary.xs.

regards,
Reinhard

--
PM Mails an rpirpag <at> gmx dot at

Reply via email to