However, I get error when trying to use my libsolv-sys crate
/home/brain/libsolv-rs/target/debug/deps/systest-3df04080070ee608.0.o: In function `systest::fn_queue_pop':
/home/brain/libsolv-rs/systest/src/main.rs:9: undefined reference to `queue_pop'
Which is obvious, because this function is not exported by library, but declared in header. How should I deal with such kind of things?
Yes, that's it. It is a bit of hassle, but this approach works with arbitrary C functions.
As @comex said, the alternative is to reimplement the function in Rust manually. That would simplify the build and give you inlining the original function was intended for.
Having functions defined in headers is common enough that it seems like the ffi interface should be extended to support it explicitly or at least provide tooling to make handling it easier.
Having language support for that is questionable (as it would make FFI geared towards C and not the ABI). But it seems like a good addition to things like bindgen.
@ignatenkobrain@kornel I've been using the rust-c crate, a fork I did of rust-cpp (forked because my build environment did not have C++ support), to let me manage the C code as part of my Rust code. This avoids the duplication.