digitalmars.D.learn - Tutorial on C++ Integration?
- Mike McKee (25/25) Sep 28 2015 I'm using Qt/C++ on a Mac. I want to try my hand at making a
- Kagamin (2/2) Sep 28 2015 http://wiki.dlang.org/Vision/2015H1 C++ integration was planned
- Jacob Carlborg (4/5) Sep 28 2015 Dynamic libraries are not officially supported on OS X.
I'm using Qt/C++ on a Mac. I want to try my hand at making a dylib in D that can receive a C++ string, reverse it, and respond with the result back to Qt/C++. Are there any easy tutorials out there with something simple like that? You probably want me to type some code so that I showed that I at least tried something. Okay, here's me just guessing: // test.dylib auto _cstr2dstr(inout(char)* cstr) { import core.stdc.string: strlen; return cstr ? cstr[0 .. strlen(cstr)] : cstr[0 .. 0]; } extern(C++) char* reverseString(char* cstr) { import std.string; import std.algorithm; s = _cstr2dstr(cstr); s = s.reverse(); return toStringz(s); } Also, what do I type to define this as a class that C++ can call, such as the following C++? QObject Foo = new Foo(); qDebug() << Foo.reverseString('bar'); Next, I'm a bit fuzzy on how to compile that into a dylib yet, as well as how to call this inside of Qt/C++ with QtCreator.
Sep 28 2015
http://wiki.dlang.org/Vision/2015H1 C++ integration was planned to be available by the end of 2015. May be too optimistic still.
Sep 28 2015
On 2015-09-28 09:08, Mike McKee wrote:I'm using Qt/C++ on a Mac. I want to try my hand at making a dylib in DDynamic libraries are not officially supported on OS X. -- /Jacob Carlborg
Sep 28 2015