Is there a way to Deferred binding symbol from dynamic library?

Dakota dakota at gmail.com
Fri Nov 22 06:13:26 UTC 2024


Try build a dynamic library, a lot function symbol and global 
symbol need to be deferred binding from runtime app.


It can be done by pass `-Wl,-undefined,dynamic_lookup` or 
`--unresolved-symbols=dynamic_lookup` to linker.


I am look a way to do it from d code, like 
`pragma(linkerDirective, "--unresolved-symbols=dynamic_lookup")`, 
  this can be more flexable when I import one module, I get that 
module linker options.  (there is a lot module they have diff 
symbol options, I need to combine them arbitrarily)


linux work since they allow undefined symbol when link dynamic 
library.

for macOS, with `pragma(linkerDirective, 
"--unresolved-symbols=dynamic_lookup");`, I get error:

```sh
lld: error: --unresolved-symbols=dynamic_lookup is not allowed in 
LC_LINKER_OPTION
```


I need to use llvm `lld -flavor ld64`.


More information about the Digitalmars-d-learn mailing list