Skip to content

posix_setup

guoling edited this page Jul 5, 2024 · 7 revisions

MMKV for POSIX

MMKV is an efficient, small, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on both Android, iOS/macOS, Windows and POSIX.

Getting Started

Prerequisites

  • Linux(Ubuntu, Arch Linux, CentOS, Gentoo), Unix(macOS, FreeBSD, OpenBSD) are supported.
  • CMake 3.8.0 and above.
  • C++ compiler that supports C++ 20 standard.

Installation Via CMake

  1. Getting source code from the git repository:
git clone https://github.com/Tencent/MMKV.git
  1. Edit your CMakeLists.txt, add those lines:
add_subdirectory(mmkv/POSIX/src mmkv)
target_link_libraries(MyApp mmkv)
  1. Add #include "MMKV.h" to your source file and we are done.

note:

  1. You can test MMKV by building & running the demo project:
cd mmkv/POSIX
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
cd demo && ./demo
  1. MMKV depends on zlib. Don't worry if there's no zlib1g-dev library installed on your computer, MMKV will use its own embedded version(zlib v1.2.11).
  2. If you are pretty sure that encryption is not needed, you can turn on the preprocess directive MMKV_DISABLE_CRYPT in Core/MMKVPredef.h to save some binary size.

What's next

Clone this wiki locally