digitalmars.D.learn - How to port a C++ library?
- Joey Peters (5/5) Mar 30 2005 I know it's *somehow* possible to port a C++ library to D (like with
- clayasaurus (5/12) Mar 30 2005 This may help http://www.digitalmars.com/d/htomodule.html
- Joey Peters (6/16) Mar 30 2005 I already know about this. C to D is pretty easy, but C++ is a different...
- clayasaurus (5/33) Mar 30 2005 How so? D has templates, classes, inheritence, mixins. D should be able
- Carlos Santander B. (4/11) Mar 30 2005 Yes: you have to create a C wrapper.
- J C Calvarese (19/24) Mar 30 2005 Well, the wxD project (http://wxd.sourceforge.net/) is already working
- Joey Peters (2/17) Mar 31 2005 Yeah, I thought of something like that. But that's a lot of work man. Th...
-
Lynn Allan
(2/4)
Apr 01 2005
As they say, "if this stuff was easy, would it pay so well?"
I know it's *somehow* possible to port a C++ library to D (like with wxWidgets). Now, I'm not a very good programmer, and I don't understand things such as how to port C++ to D. Porting the headers won't work I know, but what steps do I have to take? Do I first have to create some sort of wrapper around the library?
Mar 30 2005
Joey Peters wrote:I know it's *somehow* possible to port a C++ library to D (like with wxWidgets). Now, I'm not a very good programmer, and I don't understand things such as how to port C++ to D. Porting the headers won't work I know, but what steps do I have to take? Do I first have to create some sort of wrapper around the library?This may help http://www.digitalmars.com/d/htomodule.html Which C++ lib are you trying to port? I think the first step is to get everything into the .h or .cc file and then follow the websites conversion guide.
Mar 30 2005
"clayasaurus" <clayasaurus gmail.com> schreef in bericht news:d2eaj6$161b$1 digitaldaemon.com...Joey Peters wrote:I already know about this. C to D is pretty easy, but C++ is a different story.I know it's *somehow* possible to port a C++ library to D (like with wxWidgets). Now, I'm not a very good programmer, and I don't understand things such as how to port C++ to D. Porting the headers won't work I know, but what steps do I have to take? Do I first have to create some sort of wrapper around the library?This may help http://www.digitalmars.com/d/htomodule.htmlWhich C++ lib are you trying to port? I think the first step is to get everything into the .h or .cc file and then follow the websites conversion guide.I'm just curious how to do it. Maybe then I can look at some library and try to port it.
Mar 30 2005
Joey Peters wrote:"clayasaurus" <clayasaurus gmail.com> schreef in bericht news:d2eaj6$161b$1 digitaldaemon.com...How so? D has templates, classes, inheritence, mixins. D should be able to do anything C++ can.Joey Peters wrote:I already know about this. C to D is pretty easy, but C++ is a different story.I know it's *somehow* possible to port a C++ library to D (like with wxWidgets). Now, I'm not a very good programmer, and I don't understand things such as how to port C++ to D. Porting the headers won't work I know, but what steps do I have to take? Do I first have to create some sort of wrapper around the library?This may help http://www.digitalmars.com/d/htomodule.htmlStart simple. There is no methology to convert C++ --> D yet, otherwise we'd have a program that does it all for us :) which would be nice.Which C++ lib are you trying to port? I think the first step is to get everything into the .h or .cc file and then follow the websites conversion guide.I'm just curious how to do it. Maybe then I can look at some library and try to port it.
Mar 30 2005
Joey Peters wrote:I know it's *somehow* possible to port a C++ library to D (like with wxWidgets). Now, I'm not a very good programmer, and I don't understand things such as how to port C++ to D. Porting the headers won't work I know, but what steps do I have to take? Do I first have to create some sort of wrapper around the library?Yes: you have to create a C wrapper. _______________________ Carlos Santander Bernal
Mar 30 2005
Joey Peters wrote:I know it's *somehow* possible to port a C++ library to D (like with wxWidgets). Now, I'm not a very good programmer, and I don't understandWell, the wxD project (http://wxd.sourceforge.net/) is already working on wrapping wxWidgets, so you might want to look at what that group has done. I'll warn you: wxWidgets is gigantic!things such as how to port C++ to D. Porting the headers won't work I know, but what steps do I have to take? Do I first have to create some sort of wrapper around the library?It really depends on how the particular project is implemented in C++. If it's a small project, it might be easiest to just "convert" all of the code to D. If the C++ compiles to a .DLL or a .lib with some handy free functions, you might be able to pretend it's regular C and get away with just a simple header (I think that might be how recls works in D, http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Phobos/StdRecls). Otherwise, if the C++ is implemented as one or more classes and no C-style wrapper is provided, you'll have to be somewhat more creative. Hopefully, you could just manage to write your own wrappers to expose the functionality as functions. I suspect that's what wxD does, but I haven't really looked at any of that code (though I did manage to compile it myself -- woo-hoo!) -- jcc7 http://jcc_7.tripod.com/d/
Mar 30 2005
It really depends on how the particular project is implemented in C++. If it's a small project, it might be easiest to just "convert" all of the code to D. If the C++ compiles to a .DLL or a .lib with some handy free functions, you might be able to pretend it's regular C and get away with just a simple header (I think that might be how recls works in D, http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Phobos/StdRecls). Otherwise, if the C++ is implemented as one or more classes and no C-style wrapper is provided, you'll have to be somewhat more creative. Hopefully, you could just manage to write your own wrappers to expose the functionality as functions. I suspect that's what wxD does, but I haven't really looked at any of that code (though I did manage to compile it myself -- woo-hoo!) -- jcc7 http://jcc_7.tripod.com/d/Yeah, I thought of something like that. But that's a lot of work man. Thanks for the help.
Mar 31 2005
Yeah, I thought of something like that. But that's a lot of workman. Thanksfor the help.As they say, "if this stuff was easy, would it pay so well?" <g>
Apr 01 2005