Build fully static library by the compiler?
kinke
noone at nowhere.com
Sun Aug 11 10:18:56 UTC 2024
On Friday, 9 August 2024 at 02:34:03 UTC, Denis Feklushkin wrote:
> Are there simple way to make a static library that also
> includes necessary standard D libraries (i.e., phobos2 and
> druntime)?
Nope, you'd have to specify the path to the libs explicitly in
the cmdline to merge them into the created static lib/archive,
e.g., `ldc2 -lib bla.d $(dirname $(dirname $(which
ldc2)))/lib/lib{druntime,phobos2}-ldc.a`.
> Compiler already knows (?) paths to default static libs because
> it have --static option which produces static executable with
> all necessary libs inside. (Although I'm not sure that it works
> by this way)
Not really; the `-defaultlib` libraries need to be in one of the
`lib-dirs` in ldc2.conf, it's the linker that resolves them.
> Point is that D can be not a main language of the project and
> it is unconvient to extract by somehow paths to phobos and
> druntime at last stages of project build.
Would using the D compiler as linker driver be an option? Similar
to how people can avoid explicitly linking GNU's libstdc++ /
LLVM's libc++ by using `c++` instead of `cc` as linker driver,
thereby not having to know which implementation of the C++ std
library to choose for the particular platform.
More information about the Digitalmars-d-learn
mailing list