On 6/13/11 4:27 AM, Jens Mueller wrote:
Steve Teale wrote:
Can DMD D2/Linux do this yet?

dmd can't do it yet. But if all you want is to link a against a shared
library you can try the following:

1. Create a shared library
$ gcc -m64 -fPIC -shared shared.c -o libshared.so

2. Building (without linking using dmd)
$ dmd -m64 -c dynamic.d -ofdynamic.o

3. Use gcc as linker
$ gcc -m64 dynamic.o /path/to//libphobos2.a -L. -lshared -lrt -o dynamic

4. Execute
$ ./dynamic
Hello from shared

I attached the files shared.c and dynamic.d, if you want to try
yourself.

Jens

Jens,


Two questions - first, what steps do we need to take to convince the linker call from within dmd to work as above?

Second, how about the converse - loading a shared library from a program written in either C or D?


Thanks,

Andrei

Reply via email to