How to get ldc2 to link dynamically to Phobos

David Nadlinger via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Sun Oct 18 03:53:46 PDT 2015


On 18 Oct 2015, at 5:07, Shriramana Sharma via digitalmars-d-ldc wrote:
> LDC doesn't seem to ship with a compiled Phobos SO

This is a restriction in our current build system that could be easily 
lifted by some refactoring; I wish somebody would take care of it 
(*hint, hint*).

> so I just symlinked it from DMD's one (not sure whether
> that is compatible or not though):

It is not; not even between different releases of the same compiler.

> ... but anyhow I keep getting the error:
>
> /usr/bin/ld: cannot find -llibphobos2.so
> collect2: error: ld returned 1 exit status
> Error: /usr/bin/gcc failed with status: 1

Seems like that's an invalid linker command, right? (DMD might detect 
whether you pass a whole file name, but I'm not sure we do, although I 
vaguely remember Kai working on something to that effect.)

> BTW why is LDC using gcc and not clang to link?

Because all we really care about is that it is a gcc-compatible C 
compiler that knows where to find its standard libraries. If not for the 
latter, we'd use the system linker directly. As for "gcc" vs. "clang", 
it turns out that for example on OS X, where Clang is the default, there 
is still a "gcc" symlink for compatibility purposes anyway (FreeBSD 
doesn't have one, though, IIRC). And on Linux, GCC is still more 
widespread than Clang, so simply using "gcc" just works on most systems.

  — David


More information about the digitalmars-d-ldc mailing list