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

For a start use dub to build D projects, it's becoming the de-facto build tool.

http://code.dlang.org/

Then take a look at one of my projects in which i've ported C headers to D.

https://github.com/nomad-software/tcltk

In that repo i've included all the C headers as well as their D counterparts for reference. Converting headers is not straightforward when you first start but once you understand the rules it gets easier. Here's some helpful links:

http://dlang.org/interfaceToC.html
http://www.gamedev.net/page/resources/_/technical/game-programming/binding-d-to-c-r3122
http://forum.dlang.org/thread/qvjjzoxoufxnxzoky...@forum.dlang.org
http://forum.dlang.org/thread/wmzqweodmbpkfjbve...@forum.dlang.org
http://forum.dlang.org/thread/fzqloumcqbdvnccva...@forum.dlang.org

Once the D file is created and imported into your program you just need to link the necessary library and you're good to go. See the `package.json` file in the above repository for how i do it for Posix and Windows. Windows DLL's are supplied in the `dist` directory.

Reply via email to