在go中使用leveldb --levi

 

github上有个比较好用的leveldb go wrapper levigo, 安装之前需现在机器上安装leveldb

当前版本的LevelDB没有带安装脚本,需自行编译安装,过程如下:

  • install leveldb:

    $ tar zxvf leveldb-1.12.0.tar.gz

    $ leveldb-1.12.0/

    $ make

    $ sudo cp -r include/leveldb /usr/include/

    $ sudo cp libleveldb.* /usr/lib/

  • install levigo:

$ go get github.com/jmhodges/levigo

 

不知道为什么,如果把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++代码时的错误一致,但一直找不到解决办法。主要是这方面的基础太差了,求路过大虾们指点

 

posted @ 2013-08-24 15:23  AndreMouche  阅读(1100)  评论(1编辑  收藏  举报