Bind D as a shared lib for ldc

Prasun Anand via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Tue Jul 25 23:53:36 PDT 2017


Hi,

I would like to bind D as a shared library so that I can call it 
from
Ruby using FFI .

I found out how to do it with DMD from this 
[post](https://wiki.dlang.org/Call_D_from_Ruby_using_FFI).

But how should I so I do it with LDC?

I tried the example from above post and get the following error:

```
$ ldc2 -shared -m64 -relocation-model=pic i.d
/usr/bin/ld: 
/home/prasun/ldclatest/ldc-1.1.0-pk9rkm4zvdp6pglam7s2/lib/libdruntime-ldc.a(errno.c.o): relocation R_X86_64_PC32 against undefined symbol `__errno_location@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Error: /usr/lib/nvidia-cuda-toolkit/bin/gcc failed with status: 1
```

Regards,
Prasun


More information about the digitalmars-d-ldc mailing list