Thread overview
How to port a C++ library?
Mar 30, 2005
Joey Peters
Mar 30, 2005
clayasaurus
Mar 30, 2005
Joey Peters
Mar 30, 2005
clayasaurus
Mar 31, 2005
J C Calvarese
Mar 31, 2005
Joey Peters
Apr 01, 2005
Lynn Allan
March 30, 2005
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?


March 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.
March 30, 2005
"clayasaurus" <clayasaurus@gmail.com> schreef in bericht news:d2eaj6$161b$1@digitaldaemon.com...
> 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

I already know about this. C to D is pretty easy, but C++ is a different story.

> 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.


March 30, 2005
Joey Peters wrote:
> "clayasaurus" <clayasaurus@gmail.com> schreef in bericht news:d2eaj6$161b$1@digitaldaemon.com...
> 
>>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
> 
> 
> I already know about this. C to D is pretty easy, but C++ is a different story.
> 

How so? D has templates, classes, inheritence, mixins. D should be able to do anything C++ can.


> 
>>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. 
> 
> 

Start 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.





March 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
March 31, 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 

Well, 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/
March 31, 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.


April 01, 2005
> Yeah, I thought of something like that. But that's a lot of work
man. Thanks
> for the help.
>
As they say, "if this stuff was easy, would it pay so well?" <g>