georust / netcdf

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

Unable to link with `netcdf` library on macOS #107

Closed sammorrell closed 1 year ago

sammorrell commented 1 year ago

Hi folks! Thank you for your hard work on developing and maintaining this crate.

I've just encountered a problem on macOS 12.5.1 that the netcdf-sys crate is not correctly linking with libnetcdf. I have tried building correctly with libnetcdf installed both via Homebrew and conda. The result is that the directory that is added to the linker has an extra /lib on the end. I have tracked this back to this line in the netcdf-sys build.rs. https://github.com/georust/netcdf/blob/bec73a99036d38c4e728e9b2d901dcfcc564b08d/netcdf-sys/build.rs#L255

By my intuition /lib should already be added by either NcInfo::from_path(), or directly from nc-config. Is this necessary for other platforms? Have I come across an edge case? Your input would be appreciated. :)

magnusuMET commented 1 year ago

A fix should be in netcdf-sys/0.5.1, please do a cargo update and let me know if this fixes the linking problems

sammorrell commented 1 year ago

Ran cargo update and got the updated netcdf-sys/0.5.1. Has indeed resolved the issue. Many thanks for the quick patch. 🙂