Compililng C++ and D together without going mad
Johan
j at j.nl
Wed Apr 29 11:38:16 UTC 2020
On Wednesday, 29 April 2020 at 10:25:31 UTC, Jan Hönig wrote:
> In my pet project, I am using some C++ libraries. The main
> file/function is also C++. All of it successfully compiles with
> cmake. Now I want to add some functionality by calling my own D
> functions (which use some other modules/projects/phobos).
>
> My questions is, what is the "proper" building tool/way.
> Do I extend my CMakeFile.txt with additional instructions,
> which basically do a "dmd -c ...".
> Do I use dub to compile the D part as a library, and use that
> in the cmake file?
> Do I use dub to compile the C++ part as well?
>
> Surely somebody has done something similar.
> Can you pinpoint me to some examples? I could go from there.
LDC is a (somewhat complex) project with D and C++ code (and
external C++ libraries).
I think it will help you if your main() is in D (such that
druntime is automatically initialized for you).
https://github.com/ldc-developers/ldc
-Johan
More information about the Digitalmars-d-learn
mailing list