Build Instructions

The BDE repositories are built using a collection of CMake modules and python helpers. More detailed build examples can be found here:

Linux & MacOS

Prerequisites

BDE CMake build system requires following software to be preinstalled and configured on the system:

  • CMake (version 3.15 or later)

  • Ninja (recommended) or GNU Make

  • Python ( only for BDE wrappers )

  • pkg-config ( For external dependencies resolution )

Note

pkg-config is required to resolve external build dependencies for the high level BDE libraries. This tool is not required to build bde itself as it does not have external dependencies.

Download BDE tools

  • Clone the bde-tools repository:

    $ git clone https://github.com/bloomberg/bde-tools.git
    
  • Add the <bde-tools>/bin to the PATH environment variable:

    $ export PATH=<bde-tools>/bin:$PATH
    

    Note

    Instead of adding bde-tools/bin to your PATH, you can also execute the scripts from bde-tools/bin directly.

  • Verify that the build helpers can correctly detect C++ compilers installed in the system:

    $ bbs_build_env list
    Avaliable compilers:
      0: gcc-10.2.1 (default)
         Compiler type: gcc
         C compiler:    /opt/bb/bin/gcc
         CXX compiler:  /opt/bb/bin/g++
         Toolchain:     /bb/bde/bbshr/bde-tools/BdeBuildSystem/toolchains/linux/gcc-default.cmake
         Description:   gcc-10.2.1
    

    bbs_build_env will detect gcc and clang compilers in the PATH environment on Unix.

Download BDE library

  • Clone the bde repository:

    $ git clone https://github.com/bloomberg/bde.git
    $ cd bde
    

Set build environment

  • This command sets environment variables that define effective ufid/uplid, compiler and build directory for subsequent commands:

    $ eval `bbs_build_env -u opt_64_cpp17`
    

Configure, build and install BDE

  • Configure the Cmake build system:

    $ bbs_build configure
    
  • Build BDE libraries:

    $ bbs_build build
    
  • Build and run all BDE unit tests:

    $ bbs_build build --test=run
    
  • Install BDE libraries and headers:

    $ bbs_build --install_dir=/bde_install --prefix=/ install
    

Create an application

Usually, Bloomberg developers do not need to compile BDE libraries. Precompiled BDE libraries are available as dpkgs.

  • Create a sample application that initializes BALL logging system and logs “Hello, World!” message ( ball_init.cpp ):

    #include <ball_log.h>
    #include <ball_loggermanager.h>
    #include <ball_loggermanagerconfiguration.h>
    #include <ball_streamobserver.h>
    
    #include <bsl_iostream.h>
    #include <bsl_memory.h>
    
    #include <unistd.h>
    
    using namespace BloombergLP;
    
    BALL_LOG_SET_NAMESPACE_CATEGORY("MAIN");
    
    int main(int argc, char ** argv)
    {
        ball::LoggerManagerConfiguration configuration;
    
        configuration.setDefaultThresholdLevelsIfValid(ball::Severity::e_INFO);
        ball::LoggerManagerScopedGuard lmGuard(configuration);
    
    
        bsl::shared_ptr<ball::StreamObserver> observer =
                                bsl::make_shared<ball::StreamObserver>(&bsl::cout);
    
        // Register file observer with the Logger Manager.
        ball::LoggerManager::singleton().registerObserver(observer, "default");
    
        // Start logging.
        BALL_LOG_INFO << "Hello, World!";
    
        return 0;
    }
    
  • Create a sample CMakeLists.txt file:

    cmake_minimum_required (VERSION 3.15)
    project (ball_init)
    
    find_package(Threads REQUIRED)
    find_package(bal REQUIRED)
    find_package(bdl REQUIRED)
    find_package(bsl REQUIRED)
    
    add_executable(ball_init ball_init.cpp)
    target_link_libraries(ball_init bal bdl bsl Threads::Threads rt)
    
  • Configure and build the application:

    $ mkdir build
    $ cd build
    $ cmake -DCMAKE_PREFIX_PATH=/bde_install/lib64/  ../
    $ cmake --build ./
    

Plain CMake build

BDE can be compiled without provided python tools with plain CMake. Commands provided here for illustration purposes only:

$ git clone https://github.com/bloomberg/bde-tools.git
$ git clone https://github.com/bloomberg/bde.git
$ mkdir build; cd build
$ cmake -DBdeBuildSystem_DIR=../bde-tools/BdeBuildSystem/ \
        -DCMAKE_TOOLCHAIN_FILE=../bde-tools/BdeBuildSystem/toolchains/linux/gcc-default.cmake \
        -DCMAKE_BUILD_TYPE=Release -DBBS_ENV_MARKER=ON ../bde
$ cmake --build ./

Note

Compiling BDE with provided python wrappers is a preferred way of building BDE libraries.

Note

BBS_ENV_MARKER is a temporary variable to select bbs build system over the old one.

Windows

Prerequisites

BDE CMake build system requires following software to be preinstalled and configured on the system:

All commands shown below are executed from the Git Bash console.

Note

You might experience errors when using console different from Git bash.

Install Microsoft Visual Studio

When installing MSVC, make sure to check “MSVC v142 build tools” and “C++/CLI support for v142 build tools” under “Desktop development with C++”.

Download BDE tools

  • Clone the bde-tools repository:

    $ git clone https://github.com/bloomberg/bde-tools.git
    
  • Add the <bde-tools>/bin to the PATH environment variable:

    $ export PATH=<bde-tools>/bin:$PATH
    

    Note

    Instead of adding bde-tools/bin to your PATH, you can also execute the scripts from bde-tools/bin directly.

  • List installed compilers:

    $ bbs_build_env list
    Available compilers:
        0: msvc-2019 -- Visual Studio 2019 (Version 16) (default)
           CXX: None
           CC : None
           Toolchain: cl-default
        1: msvc-2017 -- Visual Studio 2017 (Version 15)
           CXX: None
           CC : None
           Toolchain: cl-default
    

Download BDE library

  • Clone the bde repository:

    $ git clone https://github.com/bloomberg/bde.git
    $ cd bde
    

Set build environment

  • This command sets environment variables that define effective ufid/uplid, compiler and build directory for subsequent commands:

    $ eval `bbs_build_env -u opt_64_cpp17`
    

Configure, build and install BDE

  • Configure the CMake build system:

    $ bbs_build configure
    

    Note

    During this step CMake generates files for low-level build system. By default the low-level build system is Ninja. If you want to generate MSVC solution, add -G msvc flag to configure command. This will generate bde.sln file that can be opened in the Visual Studio.

    Note

    MSVC solution for BDE libraries tends to be very large due to inclusion of all the test binaries as individual projects. It is possible to limit the number of test drivers included in the solution by providing --regex flag. For example --regex ball will include only test drivers for ball package. This will significantly minimize the solution generation, load and build time.

  • Build BDE libraries:

    $ bbs_build build
    
  • Build and run all BDE unit tests:

    $ bbs_build build --test=run
    
  • Install BDE libraries and headers:

    $ bbs_build --install_dir=/bde_install --prefix=/ install
    

Plain CMake build

BDE can be compiled without provided python tools with plain CMake. Commands provided here for illustration purposes only:

$ git clone https://github.com/bloomberg/bde-tools.git
$ git clone https://github.com/bloomberg/bde.git
$ mkdir build; cd build
$ cmake -DBdeBuildSystem_DIR=../bde-tools/BdeBuildSystem/ -DCMAKE_TOOLCHAIN_FILE=../bde-tools/BdeBuildSystem/toolchains/win32/cl-default.cmake \
        -DCMAKE_BUILD_TYPE=Release -DBBS_ENV_MARKER=ON ../bde
$ cmake --build ./

Note

Compiling BDE with provided python wrappers is a preferred way of building BDE libraries.