Closed kinghajj closed 7 years ago
Do you have a libmodbus installation on your system? This implementation needs a very recent libmodbus version, bf3004743cb5dcab6937946c7791770ed5d1f410 at the moment.
The build.rs is so constructed that it first tries to find a libmodbus via pkg-config. If successful build.rs use this one. If no libmodbus is found the build.rs compiles the libmodbus from the git submodule part of this crate.
But the more I think about your error, I think there must be an other problem.
I think I need more infos about your setup...
I don't believe I have installed any libmodbus; I thought from the repository layout that one was included as a submodule and would be built along with libmodbus-sys. I'm on Fedora and just dnf install libmodbus-devel
, which is version 3.0.6-1, but got the same errors. I'll try building the library at that SHA1 and report back what happens then.
Sure that's the problem. Your dnf install libmodbus-devel
installs version 3.0.6-1 of libmodbus. But this crate needs a libmodbus > version 3.1.4.
So you have two options.
1) install libmodbus from source https://github.com/stephane/libmodbus#installation. This should overwrite your local 3.0.6-1 installation.
or
2) deinstall your local 3.0.6-1 libmodbus dnf remove libmodbus-devel
. If you have no local libmodbus the crates build.rs file compiles the right one from the crates sub module.
Both solution should work for you.
I tried both options, and keep getting the same errors. I'm looking at the bindings in the target
directory, and it indeed looks like some parts are just getting skipped. For instance, here's a section from modbus-rtu.h
:
#define MODBUS_RTU_RS232 0
#define MODBUS_RTU_RS485 1
#define MODBUS_RTU_RTS_NONE 0
#define MODBUS_RTU_RTS_UP 1
#define MODBUS_RTU_RTS_DOWN 2
And here's the bindings generated from that:
pub const MODBUS_RTU_RS232: ::std::os::raw::c_uint = 0;
pub const MODBUS_RTU_RTS_NONE: ::std::os::raw::c_uint = 0;
pub const MODBUS_RTU_RTS_UP: ::std::os::raw::c_uint = 1;
Maybe this is some sort of weird bindgen bug?
Bindgen was my next bet. Please check the bindgen requirements https://servo.github.io/rust-bindgen/requirements.html
It seems like this is caused by a bug in bindgen; gonna close this issue and open one for that project.
Yeah, we debugged this this evening, and it's due to a libclang bug (which is the library that bindgen uses). In particular it's https://llvm.org/bugs/show_bug.cgi?id=9069, which I fixed in https://reviews.llvm.org/D26446, so it's libclang 4.0+ only unfortunately.
I couldn't find a good solution for this while chatting on IRC, but I think I got one that is good enough and simple.
I'm wondering, does this issue only manifest with Clang 3.9? Which version do you use, zzeroo?
It does manifest with any version previous to 4.0. I've opened https://github.com/servo/rust-bindgen/pull/750, if you verify that fixes the issue, it'd be rad :)
@kinghajj I use clang 4.0, the travis CI as well https://github.com/zzeroo/libmodbus-rs/blob/master/.travis.yml#L16. These builds are working
On docs.rs I've an issue as well. I think the cause is the same: https://docs.rs/crate/libmodbus-rs/0.4.3/builds/59047
I just made a new, empty project and added libmodbus-rs to my Cargo dependencies. After installing a few tools (clang, LLVM, automake), I eventually ran into these errors:
Any ideas? Are features of the C library being elided because of other dependencies I'm missing, causing bindgen's output to exclude them?