fatal error: 'libsecp256k1/include/secp256k1.h' file not found (solved)

foreword

When dealing with the blockchain project today, I used some packages because I needed to obtain some basic information or query information of the chain. After writing and running the test, the error reported is as follows: The blockchain uses: fisco-bcos go
insert image description here
version
:
1.16Edit Device: goland
Editing environment: local computer mac osx system

problem causes

After writing the logic and running the project to prepare for the test, the compilation encountered the above error fatal error: 'libsecp256k1/include/secp256k1.h' file not found, and then I found some information to solve it. Because I use go mod vender, I also try
again Re-vender or go mod tidy but it is not in my vender, it may be an error in the cross-compilation with Ethereum dependencies in the mac osx environment.

solution

The solution is to manually move these files to the vendor directory:
replace ${GOPATH} in the following command with your own gopath (go env to view the local gopath address)

cp -r \
  "${GOPATH}/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1" \
  "vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/"

Of course, I also encountered something wrong with GOPATH, that is, the GOPATH in the above error report is not the real place where I store gopath. At this time,
insert image description here
I will open the dependencies under the project, for example, mine is

/users/ic_xcc/development/go/pkg/mod/github.com/ethereum/[email protected]/crypto/secp256k1/libsecp256k1

The pkg/mod part was missed through gopath before, so this is also one of the ways to determine the dependencies of your own package. In short, after confirmation, you can replace the above part and manually move it to the vendor.
insert image description here
My full command is as follows:

 cp -r \
  "/users/ic_xcc/development/go/pkg/mod/github.com/ethereum/[email protected]/crypto/secp256k1/libsecp256k1" \
  "vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/"

The execution is successful as shown below
insert image description here
. This solves the problem of cross-compilation with Ethereum dependencies in the mac osx environment.

reference article

Cross-compilation in mac osx environment including Ethereum dependency error solution

Guess you like

Origin blog.csdn.net/ic_xcc/article/details/124456791