Skip to main content

How to Build

Get source

git clone https://github.com/alibaba/PhotonLibOS.git

Install dependencies

dnf install git gcc-c++ cmake
dnf install openssl-devel libcurl-devel libaio-devel zlib-devel

Build from source

cd PhotonLibOS
cmake -B build
cmake --build build -j 8
info

All the libs and executables will be saved in build/output.

Examples / Testing

The examples and test code are built together.

# Install additional dependencies
dnf install epel-release
dnf config-manager --set-enabled powertools
dnf install gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel

# Build examples and test code
cmake -B build -D PHOTON_BUILD_TESTING=ON
cmake --build build -j 8

# Run all test cases
cd build
ctest

Extra Build Options

OptionDefaultDescription
CMAKE_BUILD_TYPEReleaseBuild type. Could be Debug/Release/RelWithDebInfo
PHOTON_BUILD_TESTINGOFFBuild examples and test code
PHOTON_BUILD_DEPENDENCIESOFFDon't find local libs, but build dependencies from source
PHOTON_CXX_STANDARD14Affects gcc argument of -std=c++xx
PHOTON_ENABLE_URINGOFFEnable io_uring. Requires liburing
PHOTON_ENABLE_FUSEOFFEnable fuse. Requires libfuse
PHOTON_ENABLE_SASLOFFEnable SASL. Requires libgsasl
PHOTON_ENABLE_FSTACK_DPDKOFFEnable F-Stack and DPDK. Requires both.
PHOTON_ENABLE_EXTFSOFFEnable extfs. Requires libe2fs
PHOTON_ENABLE_ECOSYSTEMOFFEnable ecosystem tools and wrappers

Case 1. Staitcally build all third-party libs

Build all the dependencies from source, so you can distribute Photon binary anywhere, as long as libc and libc++ versions suffice.

cmake -B build -D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D PHOTON_BUILD_TESTING=ON \
-D PHOTON_BUILD_DEPENDENCIES=ON \
-D PHOTON_ENABLE_URING=ON \
-D PHOTON_AIO_SOURCE=https://pagure.io/libaio/archive/libaio-0.3.113/libaio-0.3.113.tar.gz \
-D PHOTON_ZLIB_SOURCE=https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz \
-D PHOTON_URING_SOURCE=https://github.com/axboe/liburing/archive/refs/tags/liburing-2.3.tar.gz \
-D PHOTON_CURL_SOURCE=https://github.com/curl/curl/archive/refs/tags/curl-7_42_1.tar.gz \
-D PHOTON_OPENSSL_SOURCE=https://github.com/openssl/openssl/archive/refs/heads/OpenSSL_1_0_2-stable.tar.gz \
-D PHOTON_GFLAGS_SOURCE=https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz \
-D PHOTON_GOOGLETEST_SOURCE=https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz
cmake -B build -D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D PHOTON_BUILD_DEPENDENCIES=ON \
-D PHOTON_AIO_SOURCE=https://pagure.io/libaio/archive/libaio-0.3.113/libaio-0.3.113.tar.gz \
-D PHOTON_CURL_SOURCE="" \
-D PHOTON_OPENSSL_SOURCE=""