编译、测试 leveldb
2015-03-03 20:57
1636 查看
准备工作
环境:Mac os x ,Linux 都可以下载leveldb 源代码github地址
编译 leveldb
(为了能够调试,修改 Makefile 为debug mode(B 模式)OPT ?= -g2)cd leveldb make
编译后会生成库文件:libleveldb.a
测试
dbtest.cpp#include <iostream> #include "leveldb/db.h" using namespace std; using namespace leveldb; int main() { DB *db ; Options op; op.create_if_missing = true; Status s = DB::Open(op,"/tmp/testdb",&db); if(s.ok()){ cout << "创建成功" << endl; s = db->Put(WriteOptions(),"abcd","1234"); if(s.ok()){ cout << "插入数据成功" << endl; string value; s = db->Get(ReadOptions(),"abcd",&value); if(s.ok()){ cout << "获取数据成功,value:" << value << endl; } else{ cout << "获取数据失败" << endl; } } else{ cout << "插入数据失败" << endl; } } else{ cout << "创建数据库失败" << endl; } delete db; return 0; }
编译、链接
g++ dbtest.cpp -o dbtest -L. -I./include -lpthread -lleveldb
运行结果:
原文地址
相关文章推荐
- Windows上面编译和简单测试一下leveldb-1.9.0
- 条件编译版本(添加自定义通信质量测试)
- 动态生成与编译(六)――测试一下CodeDOM生成的类
- 由成幻OnlineJudge学习如何做自己的Acm-Icpc在线评判系统-5.在线编译与测试系统代码粗解
- 0420 测试记录 gcc 编译时 库文件 头文件问题及其解决方案
- 首次编译安装测试passthru
- [转]工作笔记——Tslib的编译和触摸屏测试
- Maven 2.0:编译、测试、部署、运行
- 测试交叉编译环境arm-elf-tools-20040427.sh安装是否成功
- 编译和安装linux内核2.6.24,并且写一个简单的内核驱动测试之
- 让编译和测试过程自动化
- Maven 2.0:编译、测试、部署、运行 和 POM.XML
- 自己动手编写,编译,测试,安装Solaris设备驱动
- 由成幻OnlineJudge学习如何做自己的Acm-Icpc在线评判系统-5.在线编译与测试系统代码粗解
- 新版YARV(基于Ruby 1.9.0 v2006-11-01)编译/安装/测试手记
- 让编译和测试过程自动化[转载收藏]
- .Net编译的COM+组件的注册测试
- 关于分段编译和测试
- Tslib的编译和触摸屏测试
- Erlang下编译和测试openpoker