Subject: bug#25584: Setting DYLD_LIBRARY_PATH doesn't work on recent macOS

From: Reuben Thomas <[email-masked]>
Date: Mon, 30 Jan 2017 22:17:10 +0000

[Apologies if this is not news; I searched the mailing list archive, but
didn't find anything about this.]

I have just been trying to debug some libtoolized code on macOS 10.12
(Sierra).

I am using lldb, to avoid going through some signing rigmarole with gdb.

When I start it up it complains about not being able to find a dynamic
library in /usr/local/lib, which is correct, as it's not there. On
investigation, DYLD_LIBRARY_PATH is correctly set, but is ignored.

As far as I can tell, this is by design: the System Integrity Protection
feature of macOS 10.11 and later disables DYLD_LIBRARY_PATH.

This means that dynamic libraries can't be loaded in-place using current
libtool (I am using 2.4.6).

At the moment, my workaround will be to install the library in
/usr/local/lib, as I don't want to disable SIP on the Mac I'm borrowing to
test a Darwin build of my code!

I guess it won't be long before such security mechanisms surface in popular
GNU/Linux distros…

I presume that the measures that XCode uses to get around this could be
used in GNU libtool (though I confess I don't know what they are, and right
now don't plan to look, as I'm not a regular Darwin user, just someone
trying to make code compile on this popular platform, sigh).

-- 
http://rrt.sc3d.org