我正在爲FFmpeg打補丁,需要調試我的代碼。我正在加載外部庫,爲了測試不同的庫版本,我將它們放在不同的文件夾中。要選擇我想使用哪一個,我一直在使用DYLD_LIBRARY_PATH=/path/to/lib/dir ./ffmpeg
,這工作正常。但是當我在lldb
內嘗試它時,它崩潰說dyld: Library not loaded
和Reason: image not found
。這用於Xcode 7.1之前的工作,但我剛剛升級並停止工作。爲什麼lldb不再轉發我的環境變量了?
這裏是我的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中的一個新bug(或者我完全瘋了,這個從來沒有用過)?我很積極lldb用於轉發DYLD_LIBRARY_PATH
環境變量,所以它不再是什麼?
編輯:這是在OS X 10.11.1上。
由Jason Molenda(他似乎是lldb開發人員之一)確認[此處](https://www.mail-archive.com/[email protected]/msg00779.html)。 –