= Welcome to BCD = BCD stands for Bindings to C(++) in D. Its most notable component is bcd.gen, which generates C or C++ bindings from .h files. Generated C++ bindings replicate the API of the underlying C++ code, but have a C layer as a gobetween, and therefore require both a D compiler and a C++ compiler. Generated C bindings are simply extern (C)'s and structs, and therefore only require a D compiler. == Project Status == Development seems to have stalled with [changeset:127 changeset 127] on 03-17-2008. == Related Efforts == These are some tools that could be helpful in using C/C++ code in a D project: * [http://www.swig.org/ SWIG]: [http://www.swig.org/Doc3.0/D.html#D SWIG and D] * [https://github.com/yebblies/magicport2]: been used to convert DMD code from C++ to D2 == Getting the source == To get the latest version of bcd.gen: {{{ svn co http://svn.dsource.org/projects/bcd/trunk/bcd.gen }}} To get the latest BCD bindings: {{{ svn co http://svn.dsource.org/projects/bcd/trunk/bindings }}} == Windows Binary == If you're using Windows and you don't want to compile it yourself, you can try this Windows binary: [http://www.dsource.org/projects/bcd/browser/downloads/bcdgen-win-116.zip?format=raw bcdgen-win-116.zip] == Howto == === Prerequisites === You will need gccxml installed. Its homepage is http://www.gccxml.org/ . You will probably need the CVS version. You will also need libxml2. Its homepage is http://xmlsoft.org/ === Compilation === To compile bcdgen, just `make` in the root directory, or `make DMD=gdmd` to use GDC. === Use === Any variables in CXXFLAGS (or CFLAGS for generating C bindings) will be picked up by gccxml in the bcd.gen process. So, you will probably need to add the flags for your tool to the environment variable. In bash, for example, you can do that like so: {{{export CXXFLAGS="$CXXFLAGS `some-config --cxxflags`"}}} To create a binding, do: {{{./bcdgen
[-C] [-A] [-I] [other options]}}} The D namespace is under bcd., so if you use the namespace 'fltk2', for example, the D interfaces will be in bcd.fltk2.*. -C puts bcd.gen in C mode instead of C++ mode. -A causes bcd.gen to output all symbols, not just those in the header file specified, which is most useful for metaheaders which #include a number of other ones. -I changes the #include line in the output C++ file (if you're using C++) to put the specified prefix before the filename. Note that the generated bindings rarely work immediately, but will require some minor tweaking. Most notably: * If the header uses structs that are never actually defined, you will need to add the definition. If it only uses pointers, you can add an empty stub definition. * If the header uses struct timeval, you'll have to import std.socket (I blame this oversight on Windows) * If you use -A, it may generate unnecessary import lines which will need to be removed (a bug I'm working on) == Current Bindings == BCD is not only a binding generator, but a collection of bindings generated with it. The current bindings are: * curses (C) * By request. Untested. If you use this binding, please post reports here. * fltk2 (C++) * The example binding, a really well-bound C++ library. Has the exact same interface in D as in C++ :) * gd2 (C) * By request. Untested. If you use this binding, please post reports here. * gtk+ (C) * (And friends: atk, cairo, gdk, glib2, pango) * It works great. Don't use it. That's what duit is for :) * libevent (C) * By request. Untested. If you use this binding, please post reports here. * libxml2 (C) * Actually used by the generator itself ... recursive dependencies are good for you. * ogg, vorbis (C) * Untested except for a basic example program, please post reports here. * tiff (C) * By request. Untested. If you use this binding, please post reports here. == Example == I'm using FLTK2 as an example binding, so you'll find incomplete bindings to it in bcd/fltk2 == Creator == bcd.gen was written, for the most part, by Gregor Richards. His home page is [http://www.codu.org/] == Starting Points == * TracGuide -- Built-in Documentation For a complete list of local wiki pages, see TitleIndex.