georust / netcdf

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

thread 'main' panicked at 'Unable to locate HDF5 root directory and/or headers.' #95

Closed Butterygames closed 2 years ago

Butterygames commented 2 years ago

Hello, I've been having this error thrown by rust-analyser since trying to use this crate. I'm not overly familiar with netcdf files so I'm not exactly sure what I need to install/ where to install it from. (honestly when I look up HDF5 I'm not sure which site to even open up haha)

magnusuMET commented 2 years ago

Most likely you are missing the hdf5-dev package if you are using e.g. ubuntu. Which platform are you on?

Butterygames commented 2 years ago

Hi, I'm running windows

magnusuMET commented 2 years ago

I am not overly proficient in windows, but maybe you need to install the hdf5 library found here? https://www.hdfgroup.org/downloads/hdf5

Butterygames commented 2 years ago

Ah, good news and bad news lol

Good news: That error message is fixed

Bad news: I got a new one thread 'main' panicked at '"C:\Program Files\HDF_Group\HDF5\1.12.1\bin" not found in PATH.'

magnusuMET commented 2 years ago

i would hope hdf5 adds itself to path and all is required is a restart of the shell/IDE. Otherwise you need to add the path to PATH as done in the CI for hdf5-sys : https://github.com/aldanor/hdf5-rust/blob/d71b03e1f3235a2a714fea5233231cc04f2c7d07/.github/workflows/ci.yml#L227

magnusuMET commented 2 years ago

It might be easier just using the static feature of this crate. This way you don't have to install anything and get a binary which is easier to copy around

Butterygames commented 2 years ago

Ah yes, a IDE restart fixed it. ty for the help :)

Butterygames commented 2 years ago

Hi again @magnusuMET sorry no problems just wanted to know about the static feature of the crate, it sounds it'd make it would be useful for future reference. How about's would I go about using it? (Sorry I'm still very new to Rust, this is part of a project I'm working on to get more familiar with it)

magnusuMET commented 2 years ago

It should be as simple as changing the dependency line in your Cargo.toml to

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

This might require cmake installed on the build machine

Butterygames commented 2 years ago

Ah gave it a shot in static mode, with cmake installed, after IDE reset. Just got this lol:

--- stderr thread 'main' panicked at ' failed to execute command: program not found is cmake not installed?

Ah well I have it working the other way for now, ty for the info :p