rocksdb ubuntu c++源码编译测试
2017-05-25 00:00
330 查看
摘要: rocksdb 5.5.0版本
环境: ubuntu16.4 需要安装 snappy gflage bz2 zstd 以及g++ 其中zstd是facebook开放源代码里的压缩的库
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
make static_lib 成功生成 librocksdb.a静太库(使用动态库,make share_lib)
cd examples/
测试 simple_example.cc 编译命令:
g++ simple_example.cc -o test -I ../include ../librocksdb.a -std=c++11 -lpthread -lrt -lsnappy -lgflags -lz -lbz2 -lzstd 成功后生成test可执行文件
./test
修改simple_example
再次编译,输出value value
环境: ubuntu16.4 需要安装 snappy gflage bz2 zstd 以及g++ 其中zstd是facebook开放源代码里的压缩的库
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
make static_lib 成功生成 librocksdb.a静太库(使用动态库,make share_lib)
cd examples/
测试 simple_example.cc 编译命令:
g++ simple_example.cc -o test -I ../include ../librocksdb.a -std=c++11 -lpthread -lrt -lsnappy -lgflags -lz -lbz2 -lzstd 成功后生成test可执行文件
./test
修改simple_example
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. #include <cstdio> #include <string> #include <iostream> #include "rocksdb/db.h" #include "rocksdb/slice.h" #include "rocksdb/options.h" using namespace rocksdb; using namespace std; std::string kDBPath = "/tmp/rocksdb_simple_example"; int main() { DB* db; Options options; // Optimize RocksDB. This is the easiest way to get RocksDB to perform well options.IncreaseParallelism(); options.OptimizeLevelStyleCompaction(); // create the DB if it's not already present options.create_if_missing = true; // open DB Status s = DB::Open(options, kDBPath, &db); assert(s.ok()); // Put key-value s = db->Put(WriteOptions(), "key1", "value"); assert(s.ok()); std::string value; // get value s = db->Get(ReadOptions(), "key1", &value); assert(s.ok()); assert(value == "value"); std::cout << value << std::endl; // atomically apply a set of updates { WriteBatch batch; batch.Delete("key1"); batch.Put("key2", value); s = db->Write(WriteOptions(), &batch); } s = db->Get(ReadOptions(), "key1", &value); assert(s.IsNotFound()); db->Get(ReadOptions(), "key2", &value); assert(value == "value"); std::cout << value << std::endl; delete db; return 0; }
再次编译,输出value value
相关文章推荐
- Linux(Ubuntu 12.04)源码编译安装gcc-4.9.1(方法一)——亲自测试通过
- Ubuntu 15.04 安装TensorFlow(源码编译) 及测试梵高作画
- Ubuntu下eclipse编译调试带makefile的c++项目源码
- VS2010 C++下编译调试MongoDB“.NET研究”源码
- 【转】ubuntu 11.10(32位系统)下编译android源码
- android2.2源码编译-Ubuntu10.04 (X86) + android2.2 + JDK1.6
- ubuntu源码编译安装php常见错误解决办法
- ubuntu15.04编译android源码
- ubuntu 编译android 源码时Openjdk 问题
- 源码编译LAMP架构,phpMyadmin管理数据库,增加xcache加速功能,通过ab测试效果。
- Ubuntu安装GoogleTest框架并测试C++代码
- Ubuntu中安装编译并测试HTK语音识别库
- Ubuntu 14.04.2安装内核源码树以及编译
- Ubuntu 17.04版本下,opencv进行源码编译安装
- Ubuntu上下载及编译Android源码
- Ubuntu12.10 内核源码外编译 linux模块--编译驱动模块的基本方法
- Ubuntu下编译Android源码全过程
- ubuntu编译并调试OpenJDK8源码实践
- Ubuntu 10.04 编译Android 2.1源码