Clang не может найти установленную Homebrew libportaudio

1923
GolDDranks

Я установил libportaudio с помощью Homebrew на OS X. Установка прошла успешно, и я убедился, что есть символические ссылки на фактические заголовки и библиотеки в /usr/local/includeи /usr/local/lib.

Однако сейчас я пытаюсь makeсвязать Rustlang ( https://github.com/JeremyLetang/rust-portaudio ), который использует библиотеки. Это терпит неудачу со следующей ошибкой:

error: linking with `cc` failed: exit code: 1 note: cc '-m64' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-o' 'target/libportaudio.dylib' 'target/portaudio.o' '-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a' 'target/portaudio.metadata.o' '-nodefaultlibs' '-fno-lto' '-Wl,-dead_strip' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lstd-4e7c5e5c' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lsync-4e7c5e5c' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lrustrt-4e7c5e5c' '-L' 'target/deps' '-L' '/Users/drasa/repo/rust-portaudio/.rust' '-L' '/Users/drasa/repo/rust-portaudio' '-lportaudio' '-lSystem' '-lpthread' '-lc' '-lm' '-dynamiclib' '-Wl,-dylib' '-lcompiler-rt' note: ld: warning: directory not found for option '-L/Users/drasa/repo/rust-portaudio/.rust' ld: library not found for -lportaudio clang: error: linker command failed with exit code 1 (use -v to see invocation)  error: aborting due to previous error 

Таким образом, кажется, что ccне ищет библиотеки из префикса / usr / local. Это должно быть так? Как я могу это изменить? Должны ли библиотеки, установленные на домашнем ПК, работать из коробки?

2

2 ответа на вопрос

1
Peter Eisentraut

Apparently, rustc calls the system cc for linking, and it is not set up to look into /usr/local/lib/ for libraries. This is arguably the fault of the Homebrew rust package. (It does appear to look for header files under /usr/local/.)

Alternatively, the rust-portaudio package could use pkg-config to locate portaudio.

I was able to let it build further by running

make COMPILER='rustc -L/usr/local/lib' 

but then it runs into other errors that I don't understand.

1
GolDDranks

I resolved this by setting

export LIBRARY_PATH="/usr/local/lib" 

After LIBRARY_PATH is set, Cargo builds rust-portaudio without a hitch too.