Compilation Issue on Ubuntu #3501
-
Environment: Operating System: Ubuntu 22.04.3 LTS Issue Description: I'm encountering an issue when attempting to compile Trust Wallet Core on Ubuntu. The compilation process involves running a script called rust-bindgen to generate C bindings from Rust code. However, during this process, I encounter syntax errors when calling cbindgen. For example, I'm seeing errors like this:
And when i run I used to be able to manually fix these syntax issues in files like tw_keypair and tw_bitcoin, but now with the last updates the code is more complex, and I'm having difficulty adapting it for compilation. Steps to Reproduce: Navigate to the rust directory. The script i used to install all dependencies on a fresh new ubuntu install
Expected Behavior: The compilation process should complete successfully without syntax errors in the generated C headers. Actual Behavior: Syntax errors are encountered while generating C headers, preventing successful compilation. Additional Information: I have attempted to address these syntax issues manually, but I would like to understand why I'm unable to compile with the original syntax. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I asked to GPT some help and he successfully fixed me some of the files, for example for
This seems to be trying to use some form of error handling or pattern matching, but the syntax isn't valid Rust. The correct syntax for using the Option type in a conditional is with if let or match. Here's a fixed version of the tw_bitcoin_legacy_calculate_transaction_fee function:
But after that i have more confusing errors, and i can't fix each file for each update... |
Beta Was this translation helpful? Give feedback.
-
Hi @alexandre10044, thank you for opening the issue. Could you please confirm if you can compile Rust part by typing cd rust
cargo build Please make sure if you do not override the Rust version via |
Beta Was this translation helpful? Give feedback.
-
Thank you for your prompt response and providing the necessary details. As per your request, I have tested the compilation of the Rust part by running cargo build, and I can confirm that it works as expected. There were no issues with the build. Additionally, I have removed oldcbindgen: (0.20.0)
And i have installed cbindgen to the latest version as suggested. Here are the commands I used:
But now cbindgen can't be called from my terminal... So now i'm getting this:
And for the override and toolchain configs, not sure if i'm doing something wrong, but this should give infos about the situation: `rustup show installed toolchainsstable-2023-06-01-x86_64-unknown-linux-gnu installed targets for active toolchainwasm32-unknown-emscripten active toolchainnightly-2023-06-27-x86_64-unknown-linux-gnu (default) |
Beta Was this translation helpful? Give feedback.
-
So now with cbindgen 0.26 successfully installed but rust-bindgen can't find cbindgen...
Here what happen when i try to cbindgen manually:
|
Beta Was this translation helpful? Give feedback.
-
Ok this was an environment issue, thanks for yur help. So for next people that have troubles like me, Just ensure cbindgen is 0.26 and maybe edit rust-bindgen script to find the executable location, For the last output i gave, they are just warnings, so we can skip them. Thanks @satoshiotomakan |
Beta Was this translation helpful? Give feedback.
Hi @alexandre10044, thank you for opening the issue.
The
let-else
syntax you mentioned is valid, it was released in rust 1.65.Could you please confirm if you can compile Rust part by typing
cd rust cargo build
Please make sure if you do not override the Rust version via
rustup override
and no toolchain configs present neither in Cargo home nor in./rust
.The last I would suggest to update cbindgen to the latest version.