GUI library for D

Adam D. Ruppe destructionator at gmail.com
Mon Apr 4 20:35:52 PDT 2011


BTW, before I gave up on it, I tried a lot of things and made
some progress in a few areas.

I actually came very close to getting a C++ object, compiled with
mingw's gcc, to link into D.

If you use coff2omf (included in the commercial Digital Mars
package), you can get the object files all in the same format.

Then, run implib (with the free DM compiler package IIRC) on the
mingw DLLs to make some .lib files.


Then link it all together... almost works. The next problem is
getting the correct C++ runtime objects in and initialized...
and that's where I gave up on it.


A similar, but much simpler approach, was to have g++ put out
a shared library. Then do implib on it to get a .lib to pass
to optlink. Boom, the program works as long as you bundle that
.dll g++ made in there too.

To communicate with your C++, use extern(C) functions. To have
C++ call back into D, pass it an extern(c) function pointer.

When I did my own Qt, I put the Qt event loop in its own thread
(created with std.concurrency.spawn), using D's message passing
to communicate with it and Qt signals/slots to keep the thread
straight on the C++ side.

Took a little setup code, but actually worked pretty well once
it was up and running. Tip though: don't actually cast things
to immutable when passing messages! The compiler's complaints
are there for a reason. Follow the rules, and it's fairly
simple and very reliable in my experience.


g++ -ogui.dll -shared mycplusplus.cpp
implib /s gui.dll gui.lib
dmd mydapp.d gui.lib


More information about the Digitalmars-d mailing list