github上有個比較好用的leveldb go wrapper levigo, 安裝以前需如今機器上安裝leveldbgit
當前版本的LevelDB沒有帶安裝腳本,需自行編譯安裝,過程以下:github
install leveldb:app
$ tar zxvf leveldb-1.12.0.tar.gzspa
$ leveldb-1.12.0/code
$ makeblog
$ sudo cp -r include/leveldb /usr/include/get
$ sudo cp libleveldb.* /usr/lib/string
install levigo:it
$ go get github.com/jmhodges/levigoio
不知道爲何,若是把leveldb的相關文件放在/usr/local對應的文件下,安裝levigo怎麼也通不過,求路過大俠指點迷津。。。
若是不把leveldb的相關文件放置/usr/對應目錄下,用levigo上給出的方案:
CGO_CFLAGS="-I/path/to/leveldb/include" CGO_LDFLAGS="-L/path/to/leveldb/lib" go get github.com/jmhodges/levigo
運行,會跑出以下錯誤:
/home/fun/workspace/study/leveldb/test/libleveldb.a(env_posix.o): In function `leveldb::(anonymous namespace)::StartThreadWrapper(void*)': env_posix.cc:(.text+0x1e): undefined reference to `operator delete(void*)' /home/fun/workspace/study/leveldb/test/libleveldb.a(env_posix.o): In function `leveldb::(anonymous namespace)::PosixEnv::NewLogger(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, leveldb::Logger**)': env_posix.cc:(.text+0x10c): undefined reference to `operator new(unsigned long)' /home/fun/workspace/study/leveldb/test/libleveldb.a(env_posix.o): In function `leveldb::(anonymous namespace)::PosixEnv::NewSequentialFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, leveldb::SequentialFile**)': env_posix.cc:(.text+0x1e1): undefined reference to `operator new(unsigned long)' env_posix.cc:(.text+0x1f7): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
這個錯誤與以前用gcc去編譯調用leveldb的C++代碼時的錯誤一致,但一直找不到解決辦法。主要是這方面的基礎太差了,求路過大蝦們指點