Skip to content

Compile And Install

mytrygithub edited this page Jul 10, 2023 · 6 revisions

Build and install ToplingDB

Currently, topling-rocks is a private repository that requires access. Users who do not have access to the repository will compile ToplingDB as the community version. The community edition has the same features as the enterprise edition except that it cannot create the SST of the ToplingZipTable. The community edition can also read the SST of the ToplingZipTable.

contact at topling.cn to get ToplingDB for Enterprise

1. Installing dependencies

sudo yum config-manager --set-enabled powertools # Some linux distributions do not require this line
sudo yum install -y liburing-devel git gcc-c++ gflags-devel libcurl-devel \
    libaio-devel cmake nfs-utils openssl-devel ncurses-devel libtirpc-devel \
    rpcgen bison libudev-devel

You can download one of our pre-compiled dynamic or static libraries, or compile it yourself:

2. clone git

git clone https://github.com/topling/toplingdb.git
cd toplingdb
git submodule update --init --recursive
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts # silent git

3. Dynamic library compilation, installation

make -j`nproc` DEBUG_LEVEL=0 shared_lib
sudo make DEBUG_LEVEL=0 install-shared

The default installation path is /usr/local, if you want to install elsewhere, specify PREFIX=somepath

sudo make install-shared DEBUG_LEVEL=0 PREFIX=/opt

3.1. Special notes

User programs should prefer to dynamically link to ToplingDB. 101

Dynamic libraries are compiled and installed with dcompact_worker installed in /$PREFIX/bin.

3.2. DEBUG_LEVEL

DEBUG_LEVEL=? complier library name link
DEBUG_LEVEL=0 release librocksdb -lrocksdb
DEBUG_LEVEL=1 Optimization debug librocksdb_debug_1 -lrocksdb_debug_1
DEBUG_LEVEL=2 debug librocksdb -lrocksdb_debug

4. Static library compilation and installation

make -j`nproc` DEBUG_LEVEL=0 static_lib
sudo make DEBUG_LEVEL=0 install-static

Static links to ToplingDB are not recommended (see 101). If you must use static links, the following precautions should be taken:

4.1. User programs must use --whole-archive

When user programs connect to ToplingDB statically, they need to add '-Wl,--whole-archive' and '--no-whole-archive' before and after. ToplingDB's plugin mechanism is designed to isolate the direct dependency of user code on plugin code. Plugins are registered through the C++ global object construction, the code that registers plugins will be automatically deleted by the linker when statically linked, so '-Wl,--whole-archive' is needed to force the linker not to delete these codes, but at the same time, it will also cause the linker to retain the really useless code.

4.2. dcompact_worker is still dynamically linked

The static library is compiled and installed without dcompact_worker, because dcompact_worker relies on the ToplingDB dynamic library and loads user-defined plugins such as CompactionFilter via LD_PRELOAD. These user-defined plugins also rely on the ToplingDB dynamic library.

So, even if the application is statically linked to ToplingDB, to use distributed Compact, the corresponding CompactionFilter and other plugins of the application must be compiled into a dynamic library and loaded into dcompact_worker via LD_PRELOAD