How to write a library

Hipreme msnmancini at hotmail.com
Sun Jan 22 00:02:43 UTC 2023


On Saturday, 21 January 2023 at 22:53:19 UTC, Matt wrote:
> I am trying to write a graphics engine for my university 
> capstone project, and really wanted to give it a try in D, as 
> both a talking point, and because I love the language. I'm 
> using dub to build the library, and the demo application 
> that'll use it.
>
> However, I've come across a problem. In C/C++, when you build a 
> library, you compile and link the source, then provide the 
> header files for the library user to include. I have built the 
> library, but what is the D equivalent to header files, and what 
> do I have to do to prepare and use my library in another 
> project?

For using your thing as a library you need to do 2 things:

1: Include the library files by using `importPaths` on dub or -I= 
on your favorite compiler
2: Add the linker flag to include the library.


importPaths don't compile your source files. Only templates and 
some ctfe features can be used when using importPaths.


More information about the Digitalmars-d-learn mailing list