iceoryx: Bindgen generating rust binding failed.
Required information
I am using rust bindgen to generate rust binding based on iceoryx-binding-c.
And found that the struct iox_notification_info_t defined here directly refers to hpp file iceoryx_posh/include/iceoryx_posh/popo/notification_info.hpp with class NotificationInfo
Observed result or behaviour:
The c-binding is not pure.
given wraper.h
#include "iceoryx_binding_c/api.h"
rust bindgen outputs error msgs as follows:
cargo:rerun-if-changed=wrapper.h
--- stderr
/usr/local/include/iceoryx_binding_c/wait_set.h:53:28: error: unknown type name 'iox_notification_info_t'
/usr/local/include/iceoryx_binding_c/wait_set.h:66:22: error: unknown type name 'iox_notification_info_t'
/usr/local/include/iceoryx_binding_c/wait_set.h:53:28: error: unknown type name 'iox_notification_info_t', err: true
/usr/local/include/iceoryx_binding_c/wait_set.h:66:22: error: unknown type name 'iox_notification_info_t', err: true
thread 'main' panicked at 'Unable to generate bindings: ()', build.rs:37:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expected result or behaviour:
api expoting normally.
class NotificationInfo should be rewrite to the struct like this
Conditions where it occurred / Performed steps:
Not export c api in iceoryx_binding_c/wait_set.h make error msgs disapear.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 23 (23 by maintainers)
Commits related to this issue
- iox-#879 add position independent property iox_add_library Signed-off-by: Christian Eltzschig <me@elchris.org> — committed to ApexAI/iceoryx by elfenpiff 2 years ago
- iox-#879 add position independent property iox_add_library Signed-off-by: Christian Eltzschig <me@elchris.org> — committed to ApexAI/iceoryx by elfenpiff 2 years ago
- Merge pull request #1420 from ApexAI/iox-#879-add-position-independent-property-to-all-iceoryx-libs iox-#879 add position independent property iox_add_library — committed to eclipse-iceoryx/iceoryx by elfenpiff 2 years ago
Patch verified, works like a charm.
Thanks for guiding me.
yeah~~~
@BH1SCW
From the first look it seems like it is maybe a different issue
We compile every library and application with
-fPICsince we require position independent code and it looks like this is missing here. Could you try to add this flag and retry again if it solves your issue.But if you are looking for a nice rust API for iceoryx you can also look at https://github.com/eclipse-iceoryx/iceoryx-rs where @elBoberido is currently creating one which we intend to release in the next weeks.
@BH1SCW Actually this issue was closed as rejected.
No, the official tool rust-bindgen from rust is not supported by official iceoryx.
the issue you described is the fact that there are mangled and pure symbols mixed in
libiceoryx_binding_c.athis patch e65780d2002beb5f79cabcd95278d5561988775b of iceoryx change all symbols become mangled in
libiceoryx_binding_c.asee the rust-bindgen usage if interested. https://github.com/ZhenshengLee/iceoryx-rust/blob/848bbbb0a9d3f27781b46db1c7db34e4421dc599/build.rs#L27-L35
@mossmaurice I think we either need to reopen it or create a new issue to wrap the content of the header in an
extern "C"block. With the current approach one cannot include the header from the binding_c into a C++ project (yes, it’s weird but people do that) without wrapping the header itself intoextern "C"which is nothing you would usually do and from my point of view has the same severity as if you do not include all the header you need and rely on the user of your header to include those.cc @elfenpiff
@ZhenshengLee I think the proper solution here would be to have the
extern "C" { ... }in the header file itself instead of just in the source file which includes the header. This ensures that there is no name mangling, no matter if a C or C++ compiler is used to compile a source file which includes this header. To test my theory, could wrap all the included header inwrapper.hin aextern "C" { ... }block and check if bindgen can still generate the bindings?