www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Dynamic and Static Linking

reply Gerald <gerald.b.nunn gmail.com> writes:
Does LDC have a way to allow static linking libphobos and 
druntime while dynamically linking everything else? If I use the 
static flag it starts trying to link everything statically 
whereas I would like to be selective about it.

The reason I'm looking for this is some Linux distributions, such 
as Fedora, have really outdated versions of LDC shared libraries 
which are not compatible with newer versions of the compiler. DMD 
does what I want but if possible I'd prefer to use LDC for 
release binaries.
Mar 18
parent reply Mike Wey <mike-wey example.com> writes:
On 03/18/2017 04:47 PM, Gerald wrote:
 Does LDC have a way to allow static linking libphobos and druntime while
 dynamically linking everything else? If I use the static flag it starts
 trying to link everything statically whereas I would like to be
 selective about it.

 The reason I'm looking for this is some Linux distributions, such as
 Fedora, have really outdated versions of LDC shared libraries which are
 not compatible with newer versions of the compiler. DMD does what I want
 but if possible I'd prefer to use LDC for release binaries.
You should be able to specify them using `-defaultlib` -defaultlib=:libphobos2.a,:libdruntime.a With the colon at the start of the library name ld will use the library name as is and won't add a lib prefix and an extension. -- Mike Wey
Mar 18
parent reply Gerald <gerald.b.nunn gmail.com> writes:
On Saturday, 18 March 2017 at 21:42:29 UTC, Mike Wey wrote:
 You should be able to specify them using `-defaultlib`

  -defaultlib=:libphobos2.a,:libdruntime.a

 With the colon at the start of the library name ld will use the 
 library name as is and won't add a lib prefix and an extension.
Thanks as always Mike, I just had to change the names to append -ldc to them and it worked great.
Mar 18
parent Matthias Klumpp <mak debian.org> writes:
On Saturday, 18 March 2017 at 22:20:16 UTC, Gerald wrote:
 On Saturday, 18 March 2017 at 21:42:29 UTC, Mike Wey wrote:
 You should be able to specify them using `-defaultlib`

  -defaultlib=:libphobos2.a,:libdruntime.a

 With the colon at the start of the library name ld will use 
 the library name as is and won't add a lib prefix and an 
 extension.
Thanks as always Mike, I just had to change the names to append -ldc to them and it worked great.
Ah! It's comma-separated! That explains why this didn't work for me when I tried it last time ^^
Mar 18