Go build fail, fatal error: rocksdb/c.h

Go build fail, fatal error: rocksdb/c.h

我正在测试项目 obc-peer

我很困惑我应该从哪里得到 github.com/**** , golang.org/**** , google.golang.org/*** * , google/****。 我错了 $GOPATH 吗?

这是 go build 和 go env 的日志:

希望有大神帮帮我......大神们

vagrant@vagrant-ubuntu-trusty-64:/opt/gopath$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/gopath"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
vagrant@vagrant-ubuntu-trusty-64:/opt/gopath/src/github.com/openblockchain/obc-peer$ go build
# github.com/openblockchain/obc-peer/vendor/github.com/tecbot/gorocksdb
vendor/github.com/tecbot/gorocksdb/backup.go:4:24: fatal error: rocksdb/c.h: No such file or directory
 // #include "rocksdb/c.h"
                        ^
compilation terminated.

看起来你还没有安装 rocksdb 库

我跟着这里就完成了。 https://github.com/openblockchain/obc-peer/issues/885

配置RocksDB相关部门

sudo apt-get install -y libsnappy-dev
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y libbz2-dev

运行 去安装 - RocksDB 的 CGO 标志

cd $GOPATH/src/github.com/openblockchain/obc-peer
CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install

您需要使用

设置 LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/rocksdb

执行前

CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install