In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains how to install and use leveldb. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install and use leveldb.
Brief introduction of leveldb installation and use of leveldb
Leveldb is a fast key-value pair storage database developed by Google with C++, providing sequential mapping from string keys to string values.
Leveldb installation downloads leveldbgit clone https://github.com/google/leveldb.git compiling leveldbcd leveldb/make
The compiled dynamic libraries and static libraries are respectively under out-shared,out-static:
Ls leveldb/out-shared/libleveldb.so.1.20ls leveldb/out-static/libleveldb.an install leveldb
Only dynamic libraries need to be installed, and static libraries can be linked directly when you compile
# cp leveldb header filesudo cp-r / leveldb/include/ / usr/include/# cp lib to / usr/lib/sudo cp / leveldb/out-shared/libleveldb.so.1.20 / usr/lib/# create linksudo ln-s / usr/lib/libleveldb.so.1.20 / usr/lib/libleveldb.so.1sudo ln-s / usr/lib/libleveldb.so.1.20 / usr/lib/libleveldb.so# update lib cachesudo ldconfig
Check to see if the installation is successful
Ls / usr/lib/libleveldb.so*# shows that the following three files are installed successfully / used by usr/lib/libleveldb.so.1.20/usr/lib/libleveldb.so.1/usr/lib/libleveldb.soleveldb
Let's write a hello_leveldb.cc to test our leveldb.
# include
# include
# include
# include
/ / include the necessary header files
# include
Using namespace std
Int main (void) {leveldb::DB * db = nullptr; leveldb::Options options; / / create the database options.create_if_missing = true; / / if the database does not exist in / tmp/testdb leveldb::Status status = leveldb::DB::Open (options, "/ tmp/testdb", & db); assert (status.ok ()); std::string key = "A" Std::string value = "a"; std::string get_value; / / write key1-> value1 leveldb::Status s = db- > Put (leveldb::WriteOptions (), key, value); / / read the value corresponding to key:people if the write is successful
If (s.ok ()) s = db- > Get (leveldb::ReadOptions (), "A", & get_value)
/ / output if (s.ok ()) if it is read successfully
Cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.