Compile and link C/C++ libs automatically
RSY
rsy_881 at gmail.com
Thu Dec 3 06:22:30 UTC 2020
On Thursday, 3 December 2020 at 06:13:10 UTC, Mike Parker wrote:
> On Thursday, 3 December 2020 at 05:08:55 UTC, RSY wrote:
>> 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?
>
> LDC is not "based on clang". It's a D frontend to LLVM, whereas
> clang is a C frontend to LLVM.
>
> Personally, I don't find it very practical to maintain a
> multi-language compiler. If the Zig developers think it's the
> way to go, more power to them. But this is the sort of thing
> that should be relegated to build tools. Should we have support
> for compiling C and C++ in dub? Absolutely (you can do it now
> to a limited degree with prebuild commands). But not built into
> the D compiler. It should be configurable (gcc vs ldc vs msvc)
> just as dub allows you to choose your D compiler.
>
> You might find dpp of interest. While it doesn't compile C or
> C++, it does allow you to include C and (to a limited degree)
> C++ headers in your D code without the need to create bindings.
>
> https://github.com/atilaneves/dpp
The reason opting for an integrated solution is for efficiency!
caching should work just like D modules, no need to spawn extra
processes, wich is slow on windows, no overheads at all,
something that just works, out of the box
I still believe there is value in that, it allows everyone to
consume the giant C ecosystem with ease, this is something nobody
should underestimate!
Today linking libraries with dub is very easy, the compilation
part is what pauses problems, specially when deciding to
crosscompile for other targets.. this becomes very annoying!
Using clang as a library, could be a solution? something opt-in
rather than opt-out to avoid imposing the dependency to everyone
More information about the Digitalmars-d
mailing list