Skip to content

Compile EN

liguoqiang edited this page Jul 14, 2020 · 4 revisions

使用Bazel编译

We use Bazel to resolve dependencies and build BaikalDB automatically. The build has been successful on Ubuntu 16.04 and CentOS 7. More platforms will be supported soon.

Ubuntu 16.04

  • Install bazel, we recommend version 0.18.1 or earlier. Later versions may be incompatible with the BUILD file. wget --no-clobber https://github.com/bazelbuild/bazel/releases/download/0.8.1/bazel-0.8.1-installer-linux-x86_64.sh && sudo /bin/bash bazel-0.8.1-installer-linux-x86_64.sh
  • Install flex, bison and openssl library: sudo apt-get install flex bison libssl-dev
  • Install g++ (v4.8.2 or later): sudo apt-get install g++
  • bazel build //:all

CentOS 7

  • Install bazel. wget --no-clobber https://github.com/bazelbuild/bazel/releases/download/0.8.1/bazel-0.8.1-installer-linux-x86_64.sh && sudo /bin/bash bazel-0.8.1-installer-linux-x86_64.sh
  • sudo yum install flex bison patch openssl-devel
  • sudo yum install gcc-c++ (v4.8.2 or later)
  • bazel build //:all

You may brew and enjoy a cup of coffee waiting for the tedious building process

使用CMake进行编译

依赖

  • C++11,GCC4.8以上
  • openssl
  • zlib
  • boost(thread, filesystem, 1.56以上)
  • rapidjson
  • apache arrow
  • gflags
  • glog
  • snappy
  • google re2
  • protobuf
  • rocksdb
  • brpc (开启GLOG, 额外依赖leveldb)
  • braft (开启GLOG)
  • libmariadb(Baikal-Client需要, 一个高性能异步Mysql连接池)
  • tcmalloc, gperf (可选)

上述依赖CMAKE会自动下载编译。如果指定了编译选项-DWITH_SYSTEM_LIBS=ON,则会使用系统依赖,需要自行手动安装。

编译

选项

选项 默认值 说明
WITH_BAIKAL_CLIENT ON 编译 baikal-client
DEBUG OFF 开启DEBUG
WITH_SYSTEM_LIBS OFF 查找系统目录的库,而不是CMake自动依赖。
WITH_DEBUG_SYMBOLS OFF 附带debug symbols
WITH_GPERF ON 链接tcmalloc and profiler

安装必备工具

Ubuntu/WSL

sudo apt-get install cmake flex bison libssl-dev

Centos

yum install cmake flex bison
yum install openssl-devel

命令

mkdir buildenv && cd buildenv
cmake .. && make