【发布时间】:2016-02-08 19:12:51
【问题描述】:
我正在为 FFmpeg 开发补丁,需要调试我的代码。我正在加载一个外部库,为了测试不同的库版本,我将它们放在不同的文件夹中。要选择我想使用的,我一直在使用DYLD_LIBRARY_PATH=/path/to/lib/dir ./ffmpeg,它工作正常。但是当我在lldb 中尝试它时,它会崩溃说dyld: Library not loaded 和Reason: image not found。这曾经在 Xcode 7.1 之前工作,但我最近刚刚升级,它停止工作。
这是我的 MVCE:
#include <stdio.h>
#include <stdlib.h>
int main() {
char* str = getenv("DYLD_LIBRARY_PATH");
if (str) puts(str);
else puts("(null)");
return 0;
}
按如下方式运行此程序会产生输出:
$ ./a.out
(null)
$ DYLD_LIBRARY_PATH=/tmp ./a.out
/tmp
看起来不错。但是当我尝试使用 lldb 时它失败了:
$ DYLD_LIBRARY_PATH=/tmp lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) run
Process 54255 launched: './a.out' (x86_64)
(null)
Process 54255 exited with status = 0 (0x00000000)
尝试在 lldb 中设置环境变量有效:
lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) env DYLD_LIBRARY_PATH=/tmp
(lldb) run
Process 54331 launched: './a.out' (x86_64)
/tmp
Process 54331 exited with status = 0 (0x00000000)
lldb 版本(来自 Xcode 7.1):
$ lldb --version
lldb-340.4.110
问题:这是一个有意的新“功能”,还是 lldb 中的一个新错误(或者我完全疯了,这从来没有用过)?我很肯定 lldb 用于转发 DYLD_LIBRARY_PATH 环境变量,那它为什么不再呢?
编辑:这是在 OS X 10.11.1 上。
【问题讨论】:
-
由 Jason Molenda(似乎是 lldb 开发人员之一)确认 here。