A question about RUSTFLAGS or other methods of configuring rustc-link-lib on OS X.
System:
- OS X 10.15
- Rust 1.42 installed via rustup
- Homebrew installed LLVM and Proj4 library.
I am wanting to build this crate https://crates.io/crates/geo with --all-features
. All features enables Serde, Proj4 and PostGIS integrations. Here is my Proj installation:
> brew info proj
proj: stable 7.0.0 (bottled), HEAD
Cartographic Projections Library
https://proj4.org/
Conflicts with:
blast (because both install a `libproj.a` library)
/usr/local/Cellar/proj/7.0.0 (57 files, 15.2MB) *
Poured from bottle on 2020-03-16 at 17:19:35
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/proj.rb
...
After git clone of https://github.com/georust/geo then I did:
cargo build --all-features
At first it failed with a missing llvm-config
, and I discovered that OS X only has a partial implementation of llvm? I installed llvm via homebrew, and then I have apparently a working llvm setup that Rust can use.
> cargo build --all-features
Compiling proj-sys v0.12.2
error: failed to run custom build command for `proj-sys v0.12.2`
Caused by:
process didn't exit successfully: `.../geo/target/debug/build/proj-sys-41f3df0f82a014a5/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-lib=proj
--- stderr
wrapper.h:1:10: fatal error: 'proj.h' file not found
wrapper.h:1:10: fatal error: 'proj.h' file not found, err: true
Aha! So I know from compiling C software in the past, that I need to tell rustc-link-lib where to find my Proj library because it's installed via Homebrew in a nonstandard location.
After reading the cargo docs and a few stackoverflow articles, I tried this RUSTFLAGS setting but got the same error:
RUSTFLAGS="-L native=/usr/local/Cellar/proj/7.0.0" cargo build --all-features
Now I am thinking I need to add some -C link-args...
as well. Or possibly a -I
for include. Various other environment variables? Should I remove the -L
?
Any suggestions would be much appreciated!
Also I am curious what would be your thought process/mental model for solving something like this?