georust / netcdf

High-level netCDF bindings for Rust
Apache License 2.0
81 stars 28 forks source link

Can't compile in Tauri on macOS (missing HDF5) #127

Open nakajimayoshi opened 7 months ago

nakajimayoshi commented 7 months ago

Platform: macOS 14.2 apple silicon

I am trying to use netcdf5 in a Tauri application. I'm starting with the basic print file example but it's running into issues at the build step with the following error:

 Compiling tauri v1.5.4
error: failed to run custom build command for `hdf5-sys v0.8.1`

Caused by:
  process didn't exit successfully: `/Users/nakaj/Documents/sandbox/nc_analyzer/metro_nc/src-tauri/target/debug/build/hdf5-sys-58f0def845f04fb4/build-script-build` (exit status: 101)
  --- stdout
  Attempting to find HDF5 via Homebrew (any version)...

  --- stderr
  thread 'main' panicked at /Users/nakaj/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hdf5-sys-0.8.1/build.rs:548:13:
  Unable to locate HDF5 root directory and/or headers.

I checked home-brew cellar and verified I already have hdf5 v1.14.3 installed.

Even after commenting out all the example code, and only importing the library, the build error persists

Solution

resolved the issue by enabling the "static" feature in the Cargo.toml:

netcdf = { version = "0.8.3", features = ["static"] }

That said, it would be nice to have some detailed instructions or a link to them for those who don't want to use a binary blob.

magnusuMET commented 7 months ago

This is blocked on https://github.com/aldanor/hdf5-rust/issues/262

For reference: The static feature builds from source and is not a binary blob per se :)

gastoneb commented 6 months ago

Commenting for posterity. Specifying the static feature was the happy path to a successful windows/msvc build for me, and as a rust newb this instruction was not clear to me either.

cargo add netcdf --features static will update your project's Cargo.toml file.

I did not try the conda method but ci.yml shows you which environment variables to set.