CMake and D
rempas at tutanota.com
Mon Aug 8 05:42:16 UTC 2022
On Saturday, 6 August 2022 at 18:22:45 UTC, Jan Allersma wrote:
> I figured out a strategy to solve te problem:
> 1) Create a C++ function which will be called in D.
> 2) Build a static C++ library with CMake and add dependencies
> (In my case: SDL libraries)
> 3) Create a new project (`dub init`).
> 4) Add these lines to `dub.json`:
> "dflags": ["-L-lstdc++"],
> "lflags": ["-Lbuild", "-lframework", "-lSDL2"],
> - `-L-lstdc++` is needed to use standard C++ functions.
> - `-Lbuild` is to add the `build` directory a library path
> (this is the directory where my earlier compiled C++ library is
> - `-lframework` is used to link my earlier compiled C++ library
> - And finally `-lSDL2` because that is a dependency used by my
> C++ library.
> Now I can add dependencies for my D code as well using `dub
Thank you for posting the solution! And you were fast enough to
it yourself before anyone can arrive with the solution ;)
Happy coding my friend!
More information about the Digitalmars-d-learn