Cargo build fails: library path to shared c library missing


#1

FreeBSD 11
Rust 1.6

The common /usr/lib and /usr/local/lib paths are not included in the cc command generated by Cargo.

Should not these be included by default? Do I really have to explicitly put them in some cargo config file? I can’t remember ever having done that on Linux so it might be a FreeBSD issue…

Edit:
export LD_LIBRARY_PATH=… does not help.
This happened when building rust-sdl but should apply to any crate that links to shared c library…


#2

Adding some more info…

When I run cargo build on my crate (simple demo app) that depends on rust-sdl2, sdl2-sys which links to libSDL builds fine. It can find the libSDL2 using pkg-config.

However, last when “cc” is run on my crate the path to libSDL2 (/usr/local/lib) is not there and linking fails…

Shouldn’t the path to libSDL used when building sdl2-sys be used also in the last “cc” command to link my binary? Think there is something missing here…


#3

Replying to myself again… Setting LD_LIBRARY_PATH did nothing but export LIBRARY_PATH=/usr/local/lib did make it build properly.