调试leveldb1
作者:互联网
0)安装gdb
apt-get update
apt install -y gdb
1)修改编译
修改编译配置Makefile第五行
OPT ?= -O0 -gdwarf-2 -g3
2)调试代码
参考https://blog.csdn.net/a1165741556/article/details/104028855
g++ -o demo demo.cpp -pthread -lleveldb -std=c++11 -g
#include <cassert> #include <iostream> #include <string> #include <leveldb/db.h> int main() { leveldb::DB* db; leveldb::Options options; options.create_if_missing = true; leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db); assert(status.ok()); std::string key = "test_key"; std::string value = "test_value"; std::string get; leveldb::Status s = db->Put(leveldb::WriteOptions(), key, value); if (s.ok()) s = db->Get(leveldb::ReadOptions(), key, &get); if (s.ok()) std::cout << "key=" << key << "\nvalue=" << get << std::endl; else std::cout << "failed to find the key!" << std::endl; delete db; return 0; }
标签:std,leveldb,db,value,leveldb1,key,include,调试 来源: https://www.cnblogs.com/jiangshifu/p/16062051.html