Why isn't DYLD_LIBRARY_PATH being propagated here?

后端 未结 1 1446
甜味超标
甜味超标 2020-12-06 06:27

I have a simple C++ program that I\'m trying to run that is linked against a version of the Boost.Thread library that I built previously. I seem to be having trouble underst

1条回答
  •  醉梦人生
    2020-12-06 06:54

    Presumably, you are running El Capitan (OS X 10.11) or later. It's a side effect of System Integrity Protection. From the System Integrity Protection Guide: Runtime Protections article:

    When a process is started, the kernel checks to see whether the main executable is protected on disk or is signed with an special system entitlement. If either is true, then a flag is set to denote that it is protected against modification. …

    … Any dynamic linker (dyld) environment variables, such as DYLD_LIBRARY_PATH, are purged when launching protected processes.

    All of the system-provided interpreters, including /bin/sh, are protected in this fashion. Therefore, when you invoke sh, all DYLD_* environment variables are purged.

    You could write a shell script which sets DYLD_LIBRARY_PATH and then executes .sconf_temp/conftest_7. You can use the the shell interpreter to execute that — indeed, you must — and the environment variable will be fine, since the purging happens when a protected executable is started. Basically, this approach is analogous to the working example in your question, but encapsulated in a shell script.

    0 讨论(0)
提交回复
热议问题