DMD, LDC, shared objects, rpath

David Nadlinger via digitalmars-d-ldc digitalmars-d-ldc at
Mon Jun 19 10:05:16 PDT 2017

On 19 Jun 2017, at 17:25, Russel Winder via digitalmars-d-ldc wrote:
> On Linux, both DMD and LDC appear to handle rpath with the option:
> 	-L-rpath=/path/to/location/of/shared/
> on OSX (El Capitan) I have LDC working but only by using:
> 	-L-Wl,rpath,/path/to/location/of/shared/
> However nothing I have tried works for DMD. Anyone any suggestions?

LDC recognises options starting with "-Wl," and passes them to the gcc 
driver rather than prefixing them with -Xlinker. However, this should be 
equivalent to just leaving off the -Wl, entirely like in your first 
example. Have a look at the linker command line (ldc2/dmd -v) to see 
what is going on; there is no magic involved in invoking the linker. 
Similarly, you can have the gcc driver display the ld command invoked.

Just as a general hint in case you don't know them already, `otool -L` 
and `install_name_tool` are also useful for dealing with shared 
libraries on OS X. Also note that D shared libraries are not supported 
by DMD on OS X yet, if that is what you are after.

  — David

More information about the digitalmars-d-ldc mailing list