linux leveldb 1.23 编译

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

yum install cmake
yum install gcc_g++
yum install git llvm
yum install llvm

从github下载leveldb, googletest, benchmark

unzip benchmark-7d0d9061d83b663ce05d9de5da3d5865a3845b79.zip
unzip googletest-662fe38e44900c007eccb65a5d2ea19df7bd520e.zip
tar -xv -f leveldb-1.23.tar.gz
mv googletest-662fe38e44900c007eccb65a5d2ea19df7bd520e googletest
mv benchmark-7d0d9061d83b663ce05d9de5da3d5865a3845b79 benchmark
rm -rf ./leveldb-1.23/third_party/googletest   ./leveldb-1.23/third_party/benchmark
mv benchmark googletest  ./leveldb-1.23/third_party/
cd leveldb-1.23/
cmake CMakeLists.txt

make && make install


vim leveldb_test.cc

#include "leveldb/db.h"
#include <iostream>

int main()
{
 // 声明
 leveldb::DB* mydb;
 leveldb::Options myoptions;
 leveldb::Status mystatus;

 // 创建
 myoptions.create_if_missing = true;
 mystatus = leveldb::DB::Open(myoptions, "testdb", &mydb);

 // 写入数据
 std::string key{"penglaiyxy"};
 std::string value{"a handsome man"};
 if (mystatus.ok()) {
    mydb->Put(leveldb::WriteOptions(), key, value);
 }

 // 读取数据
 std::string key_ {"penglaiyxy"};
 std::string val_;
 mydb->Get(leveldb::ReadOptions(), key_, &val_);
 std::cout << key_ << ": " << val_ << std::endl;
}

 g++ leveldb_test.cc -lleveldb -lpthread  -o leveldb_test

[root@leveldbstar penglaiyxy]# ./leveldb_test
penglaiyxy: a handsome man
 

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: linux