trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.86k stars 1.6k forks source link

The compiled .a file package hints armv7 error. #710

Closed Jinxiansen closed 5 years ago

Jinxiansen commented 5 years ago

Hello! when I imported the C++ compiled 3 .a files into a golang project and packaged them via golang's gomobile bind -target=ios . command line, I got several errors like this:

333

The main mistakes are: 1.

Undefined symbols for architecture armv7:
   "_TWStringCreateWithUTF8Bytes", referenced from:
       __cgo_6474d59cea1a_Cfunc_TWStringCreateWithUTF8Bytes in _x002.o
      (maybe you meant: __cgo_6474d59cea1a_Cfunc_TWStringCreateWithUTF8Bytes)
   "_TWStringUTF8Bytes", referenced from:
       __cgo_6474d59cea1a_Cfunc_TWStringUTF8Bytes in _x002.o
      (maybe you meant: __cgo_6474d59cea1a_Cfunc_TWStringUTF8Bytes)
Ld: symbol(s) not found for architecture armv7
Clang: error: linker command failed with exit code 1 (use -v to see invocation)

The above error seems to be a problem with the support of the CPU architecture. We only need to support 64-bit systems. What do we need to do during the compilation process?

2.

  "_point_mul", referenced from:
      _sm2_std_enc in _x002.o
      _sm2_std_dec in _x002.o
      _sm2_std_genPubkey in _x002.o
      _sm2_std_sign in _x002.o
      _sm2_std_verify in _x002.o
      _sm2_std_enc in _x002.o
      _sm2_std_ka_initiator_step2 in _x002.o
      _sm2_std_ka_responder_step1 in _x002.o

This seems to be a method conflict, but I didn't find it in wallet-core, I don't know how to modify it to avoid conflicts with these files in my project.

English is not my native language; please excuse typing errors.

hewigovens commented 5 years ago

why gomobile? you can use native swfit / java wallet core bindings. could you please join https://t.me/walletcore ? for such questions?

Telegram
Trust Developers - Public
Public discussion for Trust Developers. Documentation available: developer.trustwallet.com Add new blockchain: developer.trustwallet.com/wallet-core/newblockchain
Jinxiansen commented 5 years ago

@hewigovens Because we already have a Golang framework file, and we only have access to several currencies.

In addition, when I looked at the information of .a, I found that it was the architecture of x86_64 bit, which should be used for 64-bit computers.

Non-fat file: libTrustWalletCore.a is architecture: x86_64

And what we need is the arm64 architecture on the phone. I don't know how to modify the source code so that the compiled .a is arm64?

hewigovens commented 5 years ago

run tools/ios-build

Jinxiansen commented 5 years ago

image

Prompt C++ method error in iOS.

hewigovens commented 5 years ago

Did you link the lib properly?

Jinxiansen commented 5 years ago

image

Yes. And in the golang project, the C++ compiled .a file was introduced, and the jar/aar package was not available on Android via gomobile because the .a static library could not be recognized.

Jinxiansen commented 5 years ago

Other than that, I don't know what else can be used to introduce wallet-core C++ projects for use in golang. The most stupid way is to refer to the C++ code and rewrite it in Golang.🤔

Jinxiansen commented 5 years ago

@hewigovens Hello,Is it supported to compile C++ source code into so library and then call it in golang.

hewigovens commented 5 years ago

You need to change the CMakeList.txt to produce shared library, the file size would be huge, I don't understand why you choose this approach, if you eventually call it on mobile, the best way is to use our prebuilt swift/java library.

The only reasonable way to use it in golang is server side, like address encoding etc.