Build From Source¶
We have tested building on various environments, including CentOS 6 to 8, Ubuntu 16.04 to 19.04, Fedora 28 to 30, GCC 7.1.0 to 9.2.0 and recent Clang++ and the devtoolset of Red Hat and CentOS. But due to the complexity of building environments, we still cannot guarantee that we have covered all kinds of situations. If any problem encountered, please fire an issue or open a pull request to let us know.
- CPU: x86_64
- Memory: 4GB at least
- Disk space: 10GB at least
- Linux: 2.3.32 or higher, check with
- glibc: 2.12 or higher, check with
- GCC: 7.1.0 or higher, check with
- CMake: 3.5.0 or higher, check with
- Access to the Internet
For the time being, Nebula Graph can only run in a x86_64 box, with Linux 2.3.32+ and glibc 2.12+.
Quick Steps to Build¶
Please note that it requires root privileges to install packages.
For CentOS, RedHat and Fedora users:
$ yum update $ yum install -y make \ m4 \ git \ wget \ unzip \ xz \ readline-devel \ ncurses-devel \ zlib-devel \ gcc \ gcc-c++ \ cmake \ gettext \ curl \ redhat-lsb-core # For CentOS 8+, RedHat 8+, and Fedora, you need install libstdc++-static, libasan $ yum install -y libstdc++-static libasan
For Debian and Ubuntu users:
$ apt-get update $ apt-get install -y make \ m4 \ git \ wget \ unzip \ xz-utils \ curl \ lsb-core \ build-essential \ libreadline-dev \ ncurses-dev \ cmake \ gettext
For Arch and Gentoo users, you can definitely handle all of these on your own, right?
To make sure your GCC and CMake are in the right version:
$ g++ version $ cmake version
Cloning the Repo¶
$ git clone https://github.com/vesoft-inc/nebula.git
If you don't care about the commit history of the repo, and to make the cloning faster, you could perform a shallow clone:
$ git clone --depth=1 https://github.com/vesoft-inc/nebula.git
Configuring and Building¶
$ cd nebula $ mkdir build $ cd build $ cmake -DENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=$PWD/install .. # N is suggested to the minimum of number of cores and half of available memory in Gigabytes $ make -jN $ make install $ ls install/ etc/ bin/ share/ scripts/
Since C++ templates are heavily used by Nebula Graph and its third party dependencies, especially Folly, fbthrift and boost, the building is very time-consuming.
For your reference, it is expected to take about 35 minutes in CPU time(less than 4 minutes with
-j16), given an Intel E5-2697 v3 processor and unit tests are disabled.
Until now, you might already have built Nebula Graph successfully. If so or not, we also provide ways to tweak the building process.
Ways to Tweak the Building¶
We provide several options to make one tweak the building, while some of these are builtins from CMake. These arguments are used at the configure(cmake) stage, like
cmake -DArgument=Value ...
By default, Nebula Graph turns on the
-Werror compiler option to regard any warnings as errors. If the building fails with such errors, you could still continue the building by set
This option allows to enable or disable the build of unit tests. We suggest to turn it off if you just need the service modules of Nebula Graph.
OFF, and the default value is
This option enables or disables the ASan building, a.k.a AddressSanitizer, which is a memory error detector. It is meant to be used by Nebula Graph developers. This option is
OFF by default.
There are a few building types supported:
Debug, to build with debug info but without optimization, which is by default
Release, to build with optimization but without debug info
RelWithDebInfo, to build with optimization AND debug info
MinSizeRel, to build with optimizations for code size
This option is to specify the location where the service modules, scripts, configuration files and tools are installed when
make install is performed. It is set to
/usr/local/nebula by default.
Normally, CMake will figure out and locate an applicable C++ compiler for us. But if your compiler installation is not at the standard location, or if you want to use a different one, you have to specify it explicitly as follows:
$ cmake -DCMAKE_C_COMPILER=/path/to/gcc/bin/gcc -DCMAKE_CXX_COMPILER=/path/to/gcc/bin/g++ .. $ cmake -DCMAKE_C_COMPILER=/path/to/clang/bin/clang -DCMAKE_CXX_COMPILER=/path/to/clang/bin/clang++ ..
This option is to enable the use of
ccache, which is for speeding up the compilation during daily development.
By default, Nebula Graph will take advantage of
ccache if it's found. So you don't have to enable it for yourself.
If you want to disable
ccache, it might be not enough to just turn
ENABLE_CCACHE off. Since on some platforms, the
ccache installation hooks up or precedes the compiler. For such a case, you have to set an environment variable
export CCACHE_DISABLE=true, or add a line
~/.ccache/ccache.conf. We may do this for you automatically in future.
Please see the official documentation for more details.
This option allows users to use an alternative linker, e.g.
gold. Options are
gold for now. Among them,
gold belong to GNU binutils, while
lld needs to install LLVM / Clang. In addition, you can use this parameter to specify the absolute path of the linker when needed.
This option is to explicitly specify the location of the third party.
Installing Third Party Manually¶
By default, at the configure(cmake) stage, a prebuilt third party will be downloaded and installed to the current build directory. If you would like to install it into another location for some reason, e.g. to rebuild by removing the whole build directory without downloading the third party again, you could perform the installation manually. Assume you are now at the build directory, run:
# To install third party to /opt requires root privilege, you could change it to another location with --prefix. $ ../third-party/install-third-party.sh --prefix=/opt/vesoft/third-party
If the third party is installed to
/opt/vesoft/third-party, which is by default if no
--prefix given, the building system of Nebula Graph would find it automatically. Otherwise, you need to specify the location with the CMake argument
NEBULA_THIRDPARTY_ROOT as mentioned above, or set an environment variable to the location and export it. The precedence for Nebula Graph to find and choose the third party is:
- The CMake argument
third-party/installin the current build directory
Install an Applicable CMake¶
For users who don't have a usable CMake installation, we provide a script to automatically download and install one for you. Assuming you are now at the build directory, run:
$ ../third-party/install-cmake.sh cmake-install CMake has been installed to prefix=cmake-install Run 'source cmake-install/bin/enable-cmake.sh' to make it ready to use. Run 'source cmake-install/bin/disable-cmake.sh' to disable it. $ source cmake-install/bin/enable-cmake.sh $ cmake --version cmake version 3.15.5
Now you have an applicable CMake ready to use. At any time, you could run the command
source cmake-install/bin/disable-cmake.sh to disable it.
Install an Applicable GCC¶
For users who don't have a usable GCC installation, we provide a prebuilt GCC and a script to automatically download and install it. Assuming you are now at the build directory, run:
# To install GCC to /opt requires root privilege, you could change it to other locations $ ../third-party/install-gcc.sh --prefix=/opt GCC-7.5.0 has been installed to /opt/vesoft/toolset/gcc/7.5.0 Performing usability tests Performing regular C++14 tests...OK Performing LeakSanitizer tests...OK Run 'source /opt/vesoft/toolset/gcc/7.5.0/enable' to start using. Run 'source /opt/vesoft/toolset/gcc/7.5.0/disable' to stop using. # Please note that the path and specific version might be different from your environment $ source /opt/vesoft/toolset/gcc/7.5.0/enable # Only PATH was setup so as not to pollute your library path # You could run 'export LD_LIBRARY_PATH=/opt/vesoft/toolset/gcc/7.5.0/lib64:$LD_LIBRARY_PATH' if needed $ g++ --version g++ (Nebula Graph Build) 7.5.0 Copyright (C) 2017 Free Software Foundation, Inc.
Now you have an applicable GCC compiler ready to use. At any time, you could run the command
source /opt/vesoft/toolset/gcc/7.5.0/disable to disable it.
To be added.