mac osx环境下交叉编译含eth的依赖出错解决方案

原创
2019/03/13 14:27
阅读数 4.5K

在mac系统下交叉编译出错

CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build报错,转而使用xgo。 应该是cgo的交叉编译还不完善。

$ go get github.com/karalabe/xgo   #生成xgo可执行程序,配置到path环境变量下
$ vim /etc/profile
export PATH=$GOPATH/bin:$PATH

$ cd $GOPATH/src/wallet_app
$ xgo -out wallet_app --targets=linux/amd64 ./   #xgo需要docker,启动docker后,执行该命令时会自动拉取镜像

生成一个wallet_app-linux-amd64文件,放到linux下运行即可。

如果用了vendor,编译时可能报错:fatal error: 'libsecp256k1/include/secp256k1.h' file not found

解决方法是手动把这些文件移到vendor目录下:

$ cp -r \
  "${GOPATH}/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1" \
  "vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/"
展开阅读全文
加载中

作者的其它热门文章

打赏
0
1 收藏
分享
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部