Thread overview | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 15, 2014 D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
I am a volunteer developer with the well-known 3D CAD FOSS project BRL-CAD: http://brlcad.org I have wanted to use D for a long time but I hadn't taken the plunge. Yesterday I advertised to the BRL-CAD community my new project to attempt to create D bindings for BRL-CAD's C libraries, and I created a branch for the project. I have been looking for specific information on creating D bindings from C headers for which there seems to be sufficient information available, but I would appreciate recommendations as to the best method. I have successfully built my first pure D program but now need to test the feasibility of my project. What I have not seen yet is the exact way to build a D program which uses D bindings and its matching C library. I have just created a Cookbook page on the D Wiki where I show my first attempt for a real GNU Makefile as an example for the project. The page link is here: http://wiki.dlang.org/Using_C_libraries_for_a_D_program I would appreciate it if an experienced D user would correct that recipe so it should compile the desired binary source correctly (assuming no errors in the input files). Thanks for any help. Best regards, -Tom |
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom Browder | On Thursday, 15 May 2014 at 22:25:47 UTC, Tom Browder via Digitalmars-d-learn wrote: > I am a volunteer developer with the well-known 3D CAD FOSS project BRL-CAD: > > http://brlcad.org > > I have wanted to use D for a long time but I hadn't taken the plunge. > Yesterday I advertised to the BRL-CAD community my new project to > attempt to create D bindings for BRL-CAD's C libraries, and I created > a branch for the project. > > I have been looking for specific information on creating D bindings > from C headers for which there seems to be sufficient information > available, but I would appreciate recommendations as to the best > method. I have successfully built my first pure D program but now > need to test the feasibility of my project. > > What I have not seen yet is the exact way to build a D program which > uses D bindings and its matching C library. I have just created a > Cookbook page on the D Wiki where I show my first attempt for a real > GNU Makefile as an example for the project. The page link is here: > > http://wiki.dlang.org/Using_C_libraries_for_a_D_program > > I would appreciate it if an experienced D user would correct that > recipe so it should compile the desired binary source correctly > (assuming no errors in the input files). > > Thanks for any help. > > Best regards, > > -Tom Hi Tom, Sadly, I lack the expertise to give you much advice. I did read through your Wiki posting though. One thing that came to mind was you used GMake. Perhaps you should consider using DUB. For example here is the DUB config file for one of my library bindings (in my case I used a static library though): { "name": "shplib", "description": "D bindings for Shapelib. Shapefile reader.", "homepage": "https://github.com/craig-dillabaugh/shplib.d", "homepage": "http://shapelib.maptools.org/", "importPaths":["."], "targetType": "sourceLibrary", "authors": [ "Craig Dillabaugh" ], "sourcePaths": ["./source"], "libs-posix" : ["libshp"] } A little nicer that GMake, more the "D way", and cross platform ... I think. Not sure exactly how you change that for linking to a .so lib. Cheers, Craig |
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Craig Dillabaugh | On Friday, 16 May 2014 at 01:16:46 UTC, Craig Dillabaugh wrote: > On Thursday, 15 May 2014 at 22:25:47 UTC, Tom Browder via Digitalmars-d-learn wrote: >> I am a volunteer developer with the well-known 3D CAD FOSS project BRL-CAD: >> >> http://brlcad.org >> >> I have wanted to use D for a long time but I hadn't taken the plunge. >> Yesterday I advertised to the BRL-CAD community my new project to >> attempt to create D bindings for BRL-CAD's C libraries, and I created >> a branch for the project. >> >> I have been looking for specific information on creating D bindings >> from C headers for which there seems to be sufficient information >> available, but I would appreciate recommendations as to the best >> method. I have successfully built my first pure D program but now >> need to test the feasibility of my project. >> >> What I have not seen yet is the exact way to build a D program which >> uses D bindings and its matching C library. I have just created a >> Cookbook page on the D Wiki where I show my first attempt for a real >> GNU Makefile as an example for the project. The page link is here: >> >> http://wiki.dlang.org/Using_C_libraries_for_a_D_program >> >> I would appreciate it if an experienced D user would correct that >> recipe so it should compile the desired binary source correctly >> (assuming no errors in the input files). >> >> Thanks for any help. >> >> Best regards, >> >> -Tom > > > Hi Tom, > Sadly, I lack the expertise to give you much advice. I did read through your Wiki posting though. One thing that came to mind was you used GMake. Perhaps you should consider using DUB. For example here is the DUB config file for one of my library bindings (in my case I used a static library though): > > { > "name": "shplib", > "description": "D bindings for Shapelib. Shapefile reader.", > "homepage": "https://github.com/craig-dillabaugh/shplib.d", > "homepage": "http://shapelib.maptools.org/", > "importPaths":["."], > "targetType": "sourceLibrary", > "authors": [ > "Craig Dillabaugh" > ], > "sourcePaths": ["./source"], > "libs-posix" : ["libshp"] > } > > A little nicer that GMake, more the "D way", and cross platform ... I think. > > Not sure exactly how you change that for linking to a .so lib. > > Cheers, > > Craig Some info on DUB can be found at: http://code.dlang.org/ |
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Craig Dillabaugh | On Thu, May 15, 2014 at 8:24 PM, Craig Dillabaugh via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > On Friday, 16 May 2014 at 01:16:46 UTC, Craig Dillabaugh wrote: >> On Thursday, 15 May 2014 at 22:25:47 UTC, Tom Browder via Digitalmars-d-learn wrote: ... >>> What I have not seen yet is the exact way to build a D program which uses D bindings and its matching C library. I have just created a Cookbook page on the D Wiki where I show my first attempt for a real GNU Makefile as an example for the project. The page link is here: >>> >>> http://wiki.dlang.org/Using_C_libraries_for_a_D_program >>> >>> I would appreciate it if an experienced D user would correct that recipe so it should compile the desired binary source correctly (assuming no errors in the input files). ... >> Sadly, I lack the expertise to give you much advice. I did read through your Wiki posting though. One thing that came to mind was you used GMake. Perhaps you should consider using DUB. For example here is the DUB config file for one of my library bindings (in my case I used a static library though): ... Thanks, Craig, I'll look into dub. Best regards, -Tom |
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom Browder |
>>> read through
>>> your Wiki posting though. One thing that came to mind was you used GMake.
>>> Perhaps you should consider using DUB. For example here is the DUB config
>>> file for one of my library bindings (in my case I used a static library
>>> though):
> ...
> Thanks, Craig, I'll look into dub.
>
> Best regards,
>
> -Tom
And use VisualD.
Frank
|
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom Browder | On 15/05/14 23:27, Tom Browder via Digitalmars-d-learn wrote: > I am a volunteer developer with the well-known 3D CAD FOSS project BRL-CAD: > > http://brlcad.org > > I have wanted to use D for a long time but I hadn't taken the plunge. > Yesterday I advertised to the BRL-CAD community my new project to > attempt to create D bindings for BRL-CAD's C libraries, and I created > a branch for the project. > > I have been looking for specific information on creating D bindings > from C headers for which there seems to be sufficient information > available, but I would appreciate recommendations as to the best > method. You can use DStep [1] to automatically generate bindings. It requires some manual tweaking afterwards but it will give you a good start. [1] https://github.com/jacob-carlborg/dstep -- /Jacob Carlborg |
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 16 May 2014 at 06:17:47 UTC, Jacob Carlborg wrote:
> On 15/05/14 23:27, Tom Browder via Digitalmars-d-learn wrote:
>> I am a volunteer developer with the well-known 3D CAD FOSS project BRL-CAD:
>>
>> http://brlcad.org
>>
>> I have wanted to use D for a long time but I hadn't taken the plunge.
>> Yesterday I advertised to the BRL-CAD community my new project to
>> attempt to create D bindings for BRL-CAD's C libraries, and I created
>> a branch for the project.
>>
>> I have been looking for specific information on creating D bindings
>> from C headers for which there seems to be sufficient information
>> available, but I would appreciate recommendations as to the best
>> method.
>
> You can use DStep [1] to automatically generate bindings. It requires some manual tweaking afterwards but it will give you a good start.
>
> [1] https://github.com/jacob-carlborg/dstep
Any plans to get any preprocessor stuff working? Presumably libclang can make this feasible.
|
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | John Colvin:
> Any plans to get any preprocessor stuff working?
Do you mean in D?
Bye,
bearophile
|
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | On Thu, May 15, 2014 at 9:56 PM, FrankLike via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: ... > And use VisualD. Thanks for the suggestion, Frank, but I don't do windows. Best, -Tom |
May 16, 2014 Re: D Newbie Trying to Use D with Major C Libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Fri, May 16, 2014 at 1:17 AM, Jacob Carlborg via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: ... > On 15/05/14 23:27, Tom Browder via Digitalmars-d-learn wrote: ... >> I have been looking for specific information on creating D bindings from C headers for which there seems to be sufficient information available, but I would appreciate recommendations as to the best method. ... > You can use DStep [1] to automatically generate bindings. It requires some manual tweaking afterwards but it will give you a good start. > > [1] https://github.com/jacob-carlborg/dstep Thanks, Jacob. I have seen that, but I've been reluctant to start using that until I get more familiar with D. But I think that is the way to go. Best regards, -Tom |
Copyright © 1999-2021 by the D Language Foundation