# Augmenting DYLD\_LIBRARY\_PATH

**URL:** <https://forums.solar2d.com/t/augmenting-dyld-library-path/338421>\
**Category:** macOS Desktop\
**Created:** [March 11, 2016, 10:12pm UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421 "2016-03-11T22:12:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![StarCrunch](https://forums.solar2d.com/user_avatar/forums.solar2d.com/starcrunch/32/67_2.png) [@StarCrunch](https://forums.solar2d.com/u/StarCrunch)\
**Post date:** [March 11, 2016, 10:12pm UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421/1 "2016-03-11T22:12:13Z")

</div>

Hi.

I need to be able to [tell a plugin](https://github.com/arrayfire/arrayfire-lua/wiki#on-osx)&nbsp;(a thin veneer over a much larger library written by others) where it can find some dynamic libraries installed separately. Through a lot of digging, I’ve found the **LSEnvironment** variable, where one can do basically

```
plist = { LSEnvironment = { DYLD\_LIBRARY\_PATH = "$DYLD\_LIBRARY\_PATH:/usr/local/lib:/usr/local/cuda/lib:/usr/local/cuda/nvvm/lib" } }

```

and for most keys the corresponding value will, indeed, be returned from later calls to&nbsp;**os.getenv(“MY\_ENV\_VAR”)**.

However, in the case of **DYLD\_LIBRARY\_PATH** , Corona fails to load, so I figure its own value is getting stomped on. I’m thus led to assume that, outside of Bash scripts, the **“$DYLD\_LIBRARY\_PATH:”** part (also tried with curly braces) doesn’t actually resolve to the current value under that key.

Am I missing anything here? If not, what might be the least intrusive alternative? The vast majority of what I’ve dug up explains how to register variables in&nbsp; **~/.bashrc** , but ostensibly that’s irrelevant to GUI apps. Would **~/.MacOSX/environment.plist** be the way to go?

I’m very green about OS X generally. Many of the sources I’ve been reading also seem to hint at abrupt divides among certain OS versions as far as how to do this sort of thing (Launch Control, etc.), and I’ve not had time to sift out what matters.

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![Perry\_Clarke](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/bc79bd/32.png) [@Perry\_Clarke](https://forums.solar2d.com/u/Perry_Clarke)\
**Post date:** [March 11, 2016, 11:35pm UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421/2 "2016-03-11T23:35:24Z")

</div>

We don’t set&nbsp; **DYLD\_LIBRARY\_PATH** when running the Simulator and it’s not something we support. &nbsp;It has it’s uses but I usually end up wondering when I thought juggling bottles of kerosene over a campfile sounded like a good idea 🙂

I recommend studying the docs. &nbsp;In Terminal:

```
man dyld

```

You can then debug library loading using the&nbsp; **DYLD\_PRINT\_\*** environment variables and by running the Simulator executable directly in a Terminal using:

```
DYLD\_LIBRARY\_PATH="$DYLD\_LIBRARY\_PATH:/usr/local/lib:/usr/local/cuda/lib:/usr/local/cuda/nvvm/lib" /Applications/CoronaSDK/Corona\ Simulator.app/Contents/MacOS/Corona\ Simulator -no-console YES

```

I took a quick look at what happens with your&nbsp; **DYLD\_LIBRARY\_PATH** but the process hangs in a mysterious way trying to load something from libJPEG.a so I don’t know what’s happening. &nbsp;Also,&nbsp; **DYLD\_LIBRARY\_PATH** &nbsp;isn’t normally set to the default value, the dynamic loader handles the default internally (unless you’ve set&nbsp; **DYLD\_FALLBACK\_LIBRARY\_PATH** which I doubt).

Your quickest way to a successful resolution of this is probably to copy (or symbolic link) your custom libraries into **/usr/local/lib**.

---

<div class="post-metadata">

**Author:** ![StarCrunch](https://forums.solar2d.com/user_avatar/forums.solar2d.com/starcrunch/32/67_2.png) [@StarCrunch](https://forums.solar2d.com/u/StarCrunch)\
**Post date:** [March 15, 2016, 6:47am UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421/3 "2016-03-15T06:47:30Z")

</div>

The juggling act sounds like quite the show!

As far as the “mysterious hang”, in my case it was an issue with libpng: I think the same symbol mentioned [here](https://stackoverflow.com/questions/26066445/trouble-with-the-libpng-dylib-from-freetype-2-5-3), though [this](https://github.com/Homebrew/homebrew/issues/34302) suggests several libraries can be at fault. Following some of the advice in the first fixed the crashes, though after that I’m not sure anything happens.&nbsp; 😛 At any rate, the plist / **os.getenv()** combo seems to have blacklisted that from **LSEnvironment**.

I’ll give the print variables thing a go once I’ve slept (I did try passing those through the plist, without any luck). Do these just need to be set to anything, or to 1, or what?

Anyhow, thanks for the help. I might have to pester the library authors a bit on this, too.&nbsp; 🙂

---

<div class="post-metadata">

**Author:** ![StarCrunch](https://forums.solar2d.com/user_avatar/forums.solar2d.com/starcrunch/32/67_2.png) [@StarCrunch](https://forums.solar2d.com/u/StarCrunch)\
**Post date:** [March 17, 2016, 12:00am UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421/4 "2016-03-17T00:00:25Z")

</div>

Well, as of a couple hours ago, I’ve got this past the first steps, though have by no means put it through its paces. Possibly related to the “fix” mentioned in my last post, a `brew reinstall libpng` seemed to be the final piece of the puzzle, though a missing “/opt/x11” (another of the “abrupt divides among certain OS versions”?) might have been contributing (at any rate, it was bringing down the SDK’s own samples).

I’ll keep the fallback path in mind for when I try to do CUDA (doesn’t look like my own GPU can do it).

Thanks!

---

<div class="post-metadata">

**Author:** ![Perry\_Clarke](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/bc79bd/32.png) [@Perry\_Clarke](https://forums.solar2d.com/u/Perry_Clarke)\
**Post date:** [March 11, 2016, 11:35pm UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421/5 "2016-03-11T23:35:24Z")

</div>

We don’t set&nbsp; **DYLD\_LIBRARY\_PATH** when running the Simulator and it’s not something we support. &nbsp;It has it’s uses but I usually end up wondering when I thought juggling bottles of kerosene over a campfile sounded like a good idea 🙂

I recommend studying the docs. &nbsp;In Terminal:

```
man dyld

```

You can then debug library loading using the&nbsp; **DYLD\_PRINT\_\*** environment variables and by running the Simulator executable directly in a Terminal using:

```
DYLD\_LIBRARY\_PATH="$DYLD\_LIBRARY\_PATH:/usr/local/lib:/usr/local/cuda/lib:/usr/local/cuda/nvvm/lib" /Applications/CoronaSDK/Corona\ Simulator.app/Contents/MacOS/Corona\ Simulator -no-console YES

```

I took a quick look at what happens with your&nbsp; **DYLD\_LIBRARY\_PATH** but the process hangs in a mysterious way trying to load something from libJPEG.a so I don’t know what’s happening. &nbsp;Also,&nbsp; **DYLD\_LIBRARY\_PATH** &nbsp;isn’t normally set to the default value, the dynamic loader handles the default internally (unless you’ve set&nbsp; **DYLD\_FALLBACK\_LIBRARY\_PATH** which I doubt).

Your quickest way to a successful resolution of this is probably to copy (or symbolic link) your custom libraries into **/usr/local/lib**.

---

<div class="post-metadata">

**Author:** ![StarCrunch](https://forums.solar2d.com/user_avatar/forums.solar2d.com/starcrunch/32/67_2.png) [@StarCrunch](https://forums.solar2d.com/u/StarCrunch)\
**Post date:** [March 15, 2016, 6:47am UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421/6 "2016-03-15T06:47:30Z")

</div>

The juggling act sounds like quite the show!

As far as the “mysterious hang”, in my case it was an issue with libpng: I think the same symbol mentioned [here](https://stackoverflow.com/questions/26066445/trouble-with-the-libpng-dylib-from-freetype-2-5-3), though [this](https://github.com/Homebrew/homebrew/issues/34302) suggests several libraries can be at fault. Following some of the advice in the first fixed the crashes, though after that I’m not sure anything happens.&nbsp; 😛 At any rate, the plist / **os.getenv()** combo seems to have blacklisted that from **LSEnvironment**.

I’ll give the print variables thing a go once I’ve slept (I did try passing those through the plist, without any luck). Do these just need to be set to anything, or to 1, or what?

Anyhow, thanks for the help. I might have to pester the library authors a bit on this, too.&nbsp; 🙂

---

<div class="post-metadata">

**Author:** ![StarCrunch](https://forums.solar2d.com/user_avatar/forums.solar2d.com/starcrunch/32/67_2.png) [@StarCrunch](https://forums.solar2d.com/u/StarCrunch)\
**Post date:** [March 17, 2016, 12:00am UTC](https://forums.solar2d.com/t/augmenting-dyld-library-path/338421/7 "2016-03-17T00:00:25Z")

</div>

Well, as of a couple hours ago, I’ve got this past the first steps, though have by no means put it through its paces. Possibly related to the “fix” mentioned in my last post, a `brew reinstall libpng` seemed to be the final piece of the puzzle, though a missing “/opt/x11” (another of the “abrupt divides among certain OS versions”?) might have been contributing (at any rate, it was bringing down the SDK’s own samples).

I’ll keep the fallback path in mind for when I try to do CUDA (doesn’t look like my own GPU can do it).

Thanks!
