Emurgo / csl-mobile-bridge

React-native bindings for Emurgo's cardano-serialization-lib (Cardano haskell Shelley)
MIT License
23 stars 12 forks source link

Error with cargo build #12

Closed Eztero closed 3 years ago

Eztero commented 3 years ago

Hello, I was trying to compile the library that is inside the rust folder with the following command: cargo build but it threw me this error: error: failed to get cardano-serialization-lib as a dependency of package react-native-haskell-shelley v0.0.8

I am not familiar with rust, but I saw that its dynamic library could be used so that it can interact with c ++. I have done some small tests with simple codes and the calls to the rust libraries work with c ++, and well, I would like to try this repositories because it contains the extern "c" and # [no_mangle] that I read that it is necessary for it to work. only that I have not been able to compile to generate that .so library for me.

I noticed that this compilation also generates a .h library, which I found fantastic to be able to know the functions that the dynamic library has.

If you could help me compile this library, I would really appreciate it.

v-almonacid commented 3 years ago

Yes, you should be able to use it in C++. It's configured to generate C headers but you can configure it to generate C++ if needed (see cbindgen.toml).

Could you please try compiling the v_almonacid/ch6582/add-basic-support-for-tx-metadata-bindings branch? If that doesn't work either, let me know and I'll take a look.

Eztero commented 3 years ago

Hi, I tried the branch you recommend but i keep getting the same error.

error: failed to get cardano-serialization-lib as a dependency of package react-native-haskell-shelley v0.0.8 (/home/debian/Documentos/Programas/react-native-haskell-shelley-v_almonacid-ch6582-add-basic-support-for-tx-metadata-bindings/rust) 

Caused by:
  failed to load source for dependency cardano-serialization-lib

Caused by:
  Unable to update https://github.com/Emurgo/cardano-serialization-lib.git#ee1d5ac2

Caused by:
  failed to update submodule binaryen

Caused by:
  failed to fetch submodule binaryen from git@github.com:WebAssembly/binaryen.git

Caused by:
  failed to authenticate when downloading repository
attempted ssh-agent authentication, but none of the usernames git succeeded

Caused by:
  no authentication available

I installed the debian binaryen package, thinking it might be that, but nothing changes, I get the same error

v-almonacid commented 3 years ago

@Eztero what rust version are you using? try on 1.41.0 (it's the version I've been using and it works fine).

Also, it looks like a git issue. You can try setting up ssh-based authentication for your GitHub account as a workaround.

Eztero commented 3 years ago

It worked :D, you were right it was a git problem, but I think it happens with my version of "cargo" I have the rust version 1.43 and its internal library is the one that gives me errors, from what I read on the internet. I made a configuration file in the path ~/.cargo/config.toml and put

[net]
git-fetch-with-cli = true

to work with the git executable client.

I have a doubt, Is it possible to create builds for armv7 or arm64 architectures?

v-almonacid commented 3 years ago

Glad it worked! And yes, you can build different targets, by doing something like

cargo build -p react-native-haskell-shelley --target armv7-apple-ios --release --lib

Just make sure the target is installed.

You can also take a look to cargo lipo, which allows you to compile for several targets at the same time, and create a single universal library. It's what we use here for building the iOS lib.