Compile and link C/C++ libs automatically

RSY rsy_881 at gmail.com
Thu Dec 3 05:08:55 UTC 2020


Hello

I tried zig for few days last month, it was pretty fun, but D 
still remains my main language, zig is way too much restrictive 
and verbose..

However, one feature that is making me very jealous was the 
ability to compile c/c++ code and automatically link the lib, and 
cache all that

This made working with C libraries MUCH easier

Since both zig and LDC are based on clang, i was wondering if the 
same could be possible with LDC?

Example: https://github.com/yurapyon/maru/blob/master/build.zig#L8

Now imagine such feature, with DUB


You add:

```json
"c-sources": [
     {
         "file": "deps/stb/stb_image.c",
         "flags": "-std=c99"
     }
],
"c-headers": [
     "deps/stb/stb_image.h"
]
```

``c-sources`` to build the library

and

``h-headers`` to resolve symbols

And LDC does all the job for you, so we do not need to depend on 
a local C/C++ compiler anymore!


CC from: https://github.com/ldc-developers/ldc/issues/3627


More information about the Digitalmars-d mailing list