ScaleWeather / eccodes

Unofficial high-level Rust bindings of the latest ecCodes release.
Apache License 2.0
7 stars 6 forks source link

Cannot compile `eccodes` #4

Closed aroblast closed 8 months ago

aroblast commented 11 months ago

Describe the bug After following documentation, command cargo build crashed with the following error:

error[E0432]: unresolved import `eccodes_sys::_IO_FILE`
  --> /Users/bastienlecorre/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eccodes-0.6.9/src/intermediate_bindings.rs:17:27
   |
   |     CODES_TYPE_UNDEFINED, _IO_FILE,
   |                           ^^^^^^^^ no `_IO_FILE` in the root

To Reproduce Steps to reproduce the behavior:

  1. cargo add eccodes
  2. cargo build

Expected behavior The compile process should finish successfully.

Screenshots

Screenshot 2023-10-19 at 23 51 43

Desktop

Additional context New to Rust, maybe an error on my part?

aroblast commented 11 months ago

Forgot to add, I understand this crate is only meant for Linux distros. What's a bit frustrating is that this library seems to compile fine, the problem is that _IO_FILE might be from a C header that doesn't get "transpiled" (don't really know if the term is correct here) into the struct definitions expected in the docs bindings. Maybe you have an idea about what to do regarding that? Thanks in advance!

Quba1 commented 11 months ago

Hi! Thanks for opening this issue. The problem has been already spotted here. But I haven't addressed it because I don't own a Mac so testing is an issue. I also believe that eccodes devs also officially support only Linux, so I never really bothered to provide MacOS support.

However, the issue seems to be mostly two lines of code: one importing the type from bindings generated by bindgen and the other using that type. In theory then, this could be resolved using conditional compilation in those two lines.

If you need this working quickly you can make necessary changes and add testing for MacOS in Github Actions and create a pull request. I will be able to review that rather soon. Otherwise, you'll need to wait for me to push the changes.

aroblast commented 11 months ago

Hi! Great news, I'll give it a try after work. I'll test things locally on my machine then I'll try to push a PR as soon as things are working on my part. Thanks for your help!

Quba1 commented 8 months ago

Thank you for your patience. Your suggestions have now been merged and published on crates.io. I hope this works for you now.

Thank you for your contribution.