rocksDB手动安装
在ubuntu上将rocksdb安装到指定目录:
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=~/software/rocksdb ..
make
make install
# 配置临时环境变量
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:~/software/rocksdb/include/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/software/rocksdb/lib/
export LIBRARY_PATH=$LIBRARY_PATH:~/software/rocksdb/lib/
测试:
#include <rocksdb/db.h>
#include <iostream>
int main() {
rocksdb::DB* db;
rocksdb::Options options;
options.create_if_missing = true;
rocksdb::Status status = rocksdb::DB::Open(options, "./db", &db);
if (!status.ok()) {
std::cerr << "Unable to open/create database: " << status.ToString() << std::endl;
return 1;
}
delete db;
return 0;
}
执行:
$ g++ test.cc -lrocksdb
$ ./a.out
$ ls db
000004.log CURRENT IDENTITY LOCK LOG MANIFEST-000005 OPTIONS-00000