Bug 20587 – _rt_loadLibrary symbol not found

Status
RESOLVED
Resolution
DUPLICATE
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2020-02-19T19:51:04Z
Last change time
2020-02-20T20:20:08Z
Assigned to
No Owner
Creator
Jonathan Arnold

Comments

Comment #0 by jarnold — 2020-02-19T19:51:04Z
I'm trying to compile a small test program: module MacOS.tf; import std.stdio; import core.runtime; void main() { void* vhandle = Runtime.loadLibrary("igvideo"); } on Mac OSX Catalina, and I am getting the following error: (dmd-2.090.1) dmd tf.d Undefined symbols for architecture x86_64: "_rt_loadLibrary", referenced from: __D4core7runtime7Runtime__T11loadLibraryZQoFMxAaZPv in tf.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: linker exited with status 1 This is similar to bug #19801, but a much simpler case.
Comment #1 by destructionator — 2020-02-19T19:55:32Z
Does it work if you do `dmd -defaultlib=libphobos2.so` ?
Comment #2 by jarnold — 2020-02-19T19:57:15Z
Thanks for the comment but no, doesn't help :(
Comment #3 by destructionator — 2020-02-19T19:58:12Z
OK, I know that helps on Linux but not mac I guess :( will have to wait till someone else gets on.
Comment #4 by pro.mathias.lang — 2020-02-20T07:16:52Z
Introduced by https://github.com/dlang/druntime/pull/593 The symbol is available on Linux but not OSX. We can (should) make it available on OSX, because linker errors are not user friendly. But even if we make it available on OSX, it is not implemented, so you'll have better luck calling `dlopen` / `dlsym` directly.
Comment #5 by jarnold — 2020-02-20T14:31:38Z
Actually, it works on Windows as well. And while linker errors are not, as you say, user friendly, even worse, I think, is to add it but not implement it. Is the fact it only works on Windows (and Linux I guess) documented anywhere?
Comment #6 by jarnold — 2020-02-20T14:34:45Z
I was having the same error with ldc2 and adding '-link-defaultlib-shared' fixed it: ldc2 -link-defaultlib-shared tf.d Is there something similar to that flag for dmd, or is that only for ldc2? https://github.com/ldc-developers/ldc/issues/3331
Comment #7 by kinke — 2020-02-20T19:59:54Z
This is a duplicate of https://issues.dlang.org/show_bug.cgi?id=16391. *** This issue has been marked as a duplicate of issue 16391 ***
Comment #8 by kinke — 2020-02-20T20:20:08Z
It works for LDC, with shared druntime only (i.e., not with static druntime), because it has proper shared druntime support on Mac too, unlike DMD. It's using a generalized `rt.sections_elf_shared` in druntime for Mac targets. So https://github.com/dlang/druntime/pull/2322 would fix this, but needs compiler support from DMD.