Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with update from 1.0.106 to 1.0.107 and higher #1283

Open
hanusek opened this issue Nov 7, 2023 · 0 comments
Open

Problem with update from 1.0.106 to 1.0.107 and higher #1283

hanusek opened this issue Nov 7, 2023 · 0 comments

Comments

@hanusek
Copy link

hanusek commented Nov 7, 2023

Hello @dtolnay !
I have a problem updating the cxx library from 1.0.106 to 1.0.107. Problem with linking.

ARCH: arm

bindings.rs:

[...]
#[cxx::bridge]
mod ffi {
    #[derive(Debug)]
    struct Item 
    {
        pub key: String,
        pub value: String,
    }
    
    #[derive(Debug)]
    #[repr(i32)]
    /// Callback type
    pub enum CbType
    {
        UNREGISTERED,
        ERROR,
        BOOL,
        U8,
        U16,
        U32,
        U64,
        F32,
    }

    /// Generic Closure in C API
    pub struct CClosure
    {
        cb: *const c_char,
        cb_args: *mut c_char
    }

    #[derive(Debug)]
    /// CAN frame in C API
    pub struct CanFrame
    {
        id: u32,
        data: Vec<u8>
    }

    #[namespace = "rust_part"]
    extern "Rust" 
    {
        type Driver;

        unsafe fn create_driver(proto_spec: &CxxString) -> Result<Box<Driver>>;
        unsafe fn encode_cfg_frame(self: &mut Driver, frame_id: &CxxString, items: &CxxVector<Item>) -> CanFrame;

        fn encode(self: &mut Driver) -> Vec<CanFrame>;
        fn decode(self: &mut Driver, can_id: u32, data: &Vec<u8>);

        unsafe fn update_output_value(self: &mut Driver, var_index: &CxxString, slot_id: u8, state: bool) -> bool;

        unsafe fn register_var_callback(self: &mut Driver, var_id: u32, var_index: &CxxString, slot_id: u32, cb_type: CbType, callback: CClosure) -> bool;
        unsafe fn register_event_callback(self: &mut Driver, callback: CClosure, cb_type: CbType) -> bool;

        fn valid_protocol(proto_spec: &CxxString) -> bool;
    }
}

Error:

/opt/etos/3.4/sysroots/x86_64-etossdk-linux/usr/libexec/arm-etos-linux-gnueabi/gcc/arm-etos-linux-gnueabi/11.2.0/real-ld: ../deps/ecp-ng/Model/protocol-model/protocol-model-rs/target/armv7-unknown-linux-gnueabihf/release/libprotocol_model_rs.a(protocol_model_rs-35ffc462398a1a8b.protocol_model_rs.4c6a09aa-cgu.11.rcgu.o): in function `<protocol_model_rs::bindings::ffi::Item as cxx::cxx_vector::VectorElement>::__vector_new':
protocol_model_rs.4c6a09aa-cgu.11:(.text._ZN89_$LT$protocol_model_rs..bindings..ffi..Item$u20$as$u20$cxx..cxx_vector..VectorElement$GT$12__vector_new17hde54fff77dbd407aE+0x0): undefined reference to `cxxbridge1$std$vector$Item$new'
collect2: error: ld returned 1 exit status

Maybe there is a problem with https://docs.rs/cxx/latest/cxx/vector/trait.VectorElement.html ?
My element is:

 struct Item 
 {
    pub key: String,
    pub value: String,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant