Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on MacOS #133

Closed
tomplex opened this issue Jan 3, 2021 · 3 comments
Closed

Build fails on MacOS #133

tomplex opened this issue Jan 3, 2021 · 3 comments

Comments

@tomplex
Copy link

tomplex commented Jan 3, 2021

Hey all,

I'm pretty new to Rust so please forgive me if there's something simple I'm missing.

I'm trying to run the example in the docs with a shapefile I have locally, but the build fails, suggesting that it can't find GDAL.

Here's the error:

$ cargo build
   Compiling gdal-sys v0.3.0
   Compiling thiserror-impl v1.0.22
error: failed to run custom build command for `gdal-sys v0.3.0`

Caused by:
  process didn't exit successfully: `/Users/tom/dev/rust/geocsv/target/debug/build/gdal-sys-be9ea9545f8d6e9b/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=GDAL_STATIC
cargo:rerun-if-env-changed=GDAL_DYNAMIC
cargo:rerun-if-env-changed=GDAL_INCLUDE_DIR
cargo:rerun-if-env-changed=GDAL_LIB_DIR
cargo:rerun-if-env-changed=GDAL_HOME
cargo:rerun-if-env-changed=GDAL_VERSION
cargo:rerun-if-env-changed=GDAL_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
thread 'main' panicked at 'No GDAL version detected', /Users/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-sys-0.3.0/build.rs:202:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

warning: build failed, waiting for other jobs to finish...
error: build failed

But I have gdal installed:

$ gdal-config --prefix
/usr/local/Cellar/gdal/3.2.0_1
$ gdal-config --version
3.2.0

After looking at the error message's environment variable suggestions, I tried setting some variables which looked promising...

$ gdal-config --cflags
-I/usr/local/Cellar/gdal/3.2.0_1/include
$ gdal-config --libs
-L/usr/local/Cellar/gdal/3.2.0_1/lib -lgdal
$ export GDAL_INCLUDE_DIR=/usr/local/Cellar/gdal/3.2.0_1/include
$ export GDAL_LIB_DIR=/usr/local/Cellar/gdal/3.2.0_1/lib
$ export GDAL_HOME=/usr/local/Cellar/gdal/3.2.0_1
$ cargo build
... error ...

But it's possible I'm setting them incorrectly.

What am I missing?

Thanks!

@jdroenner
Copy link
Member

i think you need pkg-config. maybe @michaelkirk can help here?

@tomplex
Copy link
Author

tomplex commented Jan 3, 2021

running brew install pkg-config allowed the build to proceed. Thanks for your response!

@michaelkirk
Copy link
Member

I've created #137 to track the work I'm going to do for better error messages when missing pkg-config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants