Ошибки привязки ржавчины — E0412 и E0428

Я пытаюсь создать привязки для большой библиотеки C++, не имея опыта работы с C++. Я постоянно натыкаюсь на стены и не знаю, как действовать дальше, поэтому надеюсь, что кто-нибудь увидит трассировку стека ошибок и узнает, что я делаю неправильно.

Когда я генерирую привязки, я получаю 6 ошибок:

      error[E0428]: the name `std__Tree_iterator` is defined multiple times
    --> C:\Users\natha\Documents\rust\libsumo\target\debug\build\libsumo-bf3a174577086181\out/bindings.rs:4398:1
     |
4259 | pub struct std__Tree_iterator {
     | ----------------------------- previous definition of the type `std__Tree_iterator` here
...
4398 | pub type std__Tree_iterator = std_conditional_t;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std__Tree_iterator` redefined here
     |
     = note: `std__Tree_iterator` must be defined only once in the type namespace of this module

error[E0412]: cannot find type `_Base` in this scope
    --> C:\Users\natha\Documents\rust\libsumo\target\debug\build\libsumo-bf3a174577086181\out/bindings.rs:4237:51
     |
4236 | pub struct std__Tree_unchecked_iterator {
     |                                        - help: you might be missing a type parameter: `<_Base>`
4237 |     pub _base: std__Tree_unchecked_const_iterator<_Base>,
     |                                                   ^^^^^ not found in this scope

error[E0412]: cannot find type `_Base` in this scope
    --> C:\Users\natha\Documents\rust\libsumo\target\debug\build\libsumo-bf3a174577086181\out/bindings.rs:4239:84
     |
4239 | pub type std__Tree_unchecked_iterator__Mybase = std__Tree_unchecked_const_iterator<_Base>;
     |                                              -                                     ^^^^^ not found in this scope
     |                                              |
     |                                              help: you might be missing a type parameter: `<_Base>`

error[E0412]: cannot find type `_Value_type` in this scope
    --> C:\Users\natha\Documents\rust\libsumo\target\debug\build\libsumo-bf3a174577086181\out/bindings.rs:4302:56
     |
4302 | pub type std__Tree_simple_types__Node = std__Tree_node<_Value_type>;
     |                                      -                 ^^^^^^^^^^^ not found in this scope
     |                                      |
     |                                      help: you might be missing a type parameter: `<_Value_type>`

error[E0412]: cannot find type `_Base` in this scope
    --> C:\Users\natha\Documents\rust\libsumo\target\debug\build\libsumo-bf3a174577086181\out/bindings.rs:4342:87
     |
4342 | pub type std__Tree_val__Unchecked_const_iterator = std__Tree_unchecked_const_iterator<_Base>;
     |                                                 -                                     ^^^^^ not found in this scope
     |                                                 |
     |                                                 help: you might be missing a type parameter: `<_Base>`

error[E0412]: cannot find type `_Base` in this scope
    --> C:\Users\natha\Documents\rust\libsumo\target\debug\build\libsumo-bf3a174577086181\out/bindings.rs:4400:83
     |
4400 | pub type std__Tree__Unchecked_const_iterator = std__Tree_unchecked_const_iterator<_Base>;
     |                                             -                                     ^^^^^ not found in this scope
     |                                             |
     |                                             help: you might be missing a type parameter: `<_Base>`

Some errors have detailed explanations: E0412, E0428.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `libsumo` due to 6 previous errors

Я надеюсь, что ошибки E0412 (то есть ошибки 5/6) можно исправить, просто добавив дженерики вручную, и я надеюсь, что это нормально? Я не уверен, почемуbindgen генерирует что-то подобное... это какой-то артефакт моей неправильной настройки?

Из-за одной ошибки E0428... Я понятия не имею, что делать. Похоже, чтоbindgen делает их оберткой для чего-то из стандартной библиотеки C++, но у меня нет опыта работы с C++, поэтому я могу ошибаться... но если это так, то зачем ему дважды обертывать одно и то же?

Мы ценим любые предложения. Я никогда раньше не работал с FFI и не имею опыта работы с C++... поэтому я ценю помощь!

Я также пробовал запустить это в Ubuntu и получал разные ошибки, но одного и того же типа (E0412 и E0428). Если не получится привязать эту C++ библиотеку, мне просто придется отказаться от Rust для этого проекта.

0 ответов

Другие вопросы по тегам