Skip to content

Latest commit

 

History

History
403 lines (360 loc) · 16.3 KB

File metadata and controls

403 lines (360 loc) · 16.3 KB

Berkeley DB C++ Framework build tools and libraries installation

Berkeley DB C++ Framework may be built for Linux or Windows. Instructions to build for these platforms follow.

Table of Contents

Linux development tools and libraries

These are instructions to prepare the Linux build environment.

Linux C++ Development Tools

Linux development tools include:

  • JetBrains CLion
  • WSL2 Linux distribution for Windows 10
  • Windows Terminal
  • Linux Build Tools
  • Git
  • Cmake

JetBrains CLion

JetBrains CLion is a free C++ IDE. The Berekeley DB C++ Framework is a Cmake project. JetBrains has a tutorial on setting up CLion for a Cmake project.

WSL2 Linux distribution for Windows 10

WSL2 is a native Linux running under Windows 10. These are instructions for installing Windows 10 WSL2. WSL2 has specific hardware requirements, including a 64-bit processor with second-level address translation (SLAT) and at least 4GB of RAM. Any new Intel Windows system should be adequate. The command to install WSL2 on Windows 10 is:

$ wsl --install

The install instructions are currently for Pengwin or Ubuntu. The Linux build is currently tested on Windows 10 WSL2 with Pengwin,

Linux Distributions

Linux development was done under Windows 10 WSL2 with Pengwin, which may be obtained from the Microsoft Store. Ubuntu may also be obtained from the Microsoft Store. The instructions likely work for other types of Linux, such as CentOS, or other types of Unix, such as MacOS, possibly with modifications. These are instructions for installing other WSL2 Linux distributions.

Windows Terminal

You likely would like to use Windows Terminal to develop using WSL2 Linux. Windows Terminal may be obtained from the Microsoft Store. This is a Microsoft tutorial for starting with Windows Terminal. Scott Hanselman has an excellent video on using Windows Terminal.

Linux Build Tools

There are several Linux C++ libraries and tools required for the build. Pengwin and Ubuntu use theaptcommand to install many Linux library and tool packages:

$ sudo apt update
$ sudo apt install <package>

Always runapt updatebeforeinstall. Some packages are not available underapt, or someaptpackages have versions that are too old to use. In those cases, they can be directly downloaded from a web site or built from source.

The Linuxbuild-essentialspackage installs the C++ compiler, debugger, libraries, other development tools required for the build. build-essentialincludes:

$ sudo apt-get update
$ sudo apt install build-essentials git

Git

git is required for the build. It can be installed with this command:

$ sudo apt-get update
$ sudo apt install git

Cmake

Berkeley DB C++ Framework is written in C++. Cmake is used for building C++ applications. The build requires the latest version, currently 3.26.1. The version available fromaptis too old to use, so it must be built from source. Select the latest source from theUnix/Linux Sourcelink on the download website, e.g.,cmake-3.26.3.tar.gz, and build with these instructions:

$ gunzip -c cmake-3.26.3.tar.gz | tar xvf -
$ cd cmake-3.26.3
$ ./configure --prefix=/usr
$ make
$ sudo make install

Cmake requires an additional tool be installed,pkg-config:

$ sudo apt-get update
$ sudo apt install pkg-config

Linux C++ Libraries

Various C++ libraries are required for the Linux build.

pthreads Library

Linuxpthreadsis a C++ threading library is required for the build. It should already be installed in Linux. In the event it is not, it can be installed with this command:

$ sudo apt-get update
$ sudo apt install libpthread-stubs0-dev

OpenSSL Library

Linux OpenSSL is a secure communications C++ library required for the build. It can be installed these instructions:

$ sudo apt-get update
$ sudo apt install openssl

Doxygen

Doxygen generates Javadoc-like html files from C++ source code. It can be installed with these instructions:

$ sudo apt-get doxygen
$ sudo apt-get opt

json-c Library

json-c is a C-based JSON manipulation library. The following will download the latest version ofjson-cfrom the git repository and build static libraries and install them in/usr/local:

$ git clone git@github.com:json-c/json-c.git
$ mkdir json-c-build
$ cd json-c-build
$ cmake ../json-c 
$ cmake --build .
$ sudo cmake --install . 

Berekley DB Library

The Berkeley DB library is an efficient, embedded non-SQL key-indexed database. The latest version is required and can be built from source. Download source for the latest version from:
https://www.oracle.com/database/technologies/related/berkeleydb-downloads.html

  • Select from the Berkeley DB version link. You may need to create an Oracle account.
  • Select theLinux x86-64 platform,read accept the license agreement, and selectDownload.
  • Run the downloaded Windows executable named Oracle_SSN_DLM_nnn.exe to create a file named Vnnnnnn-nn.zip.
  • Select Open Destination from the opened window to find the zip.
  • Right-click/drag the zip using File Explorer and select Expand into a directory named Vnnnnnn-nn.

Build using these instructions.

Install these with:

$ sudo apt-get update
$ sudo apt-get install autoconf
$ sudo apt-get install libtool
$ sudo apt install libssl-dev
$ sudo apt install libdb5.3-dev

To build, let BDB_HOME be the Berkeley DB installation directory, e.g.,Vnnnnnn-nn/db-18.1.40:

$ cd $BDB_HOME/build_unix
$ ../dist/configure --prefix=/usr --enable-cxx 
$ make
$ sudo make install

There are some otherconfigure arguments described in these files:

  • $BDB_HOME/docs/installation/build_unix_conf.html
  • $BDB_HOME/docs/installation/build_unix_flags.html

Windows development tools and libraries installation

  • Windows development was done under Windows 10
    • Windows 11 is claimed compatible but is reportedly bloatware

Windows C++ Development Tools

Following are Windows tools used for development.

Visual Studio 2022

This is the Windows C++ development environment used.

Required Visual Studio components

This section includes Visual Studio components required to build the project.

  • Download Visual Studio 2022 Community
  • Select the following Modules:
    • .NET desktop development
    • Desktop development with C++
    • Universal Windows Platform development
  • Select the following Individual Component:
    • Class Designer
  • Install the following extensions:
    • Select Extensions->Manage Extensions
    • Install these extensions
      • Search formarkdownand selectMarkdown editor (64-bit)
      • Search forjsonand selectJson formatter
      • Search for 'doxygen' and select 'Doxygen Comments' by Finn Gegenmantel
    • Restart Visual Studio

Git

Download and run the 64-bit Git for Windows installer from the Git download website.

Cmake

Berkeley DB C++ Framework is written in C++. Cmake is used for building C++ applications. The build requires the latest version, currently 3.26.1. Select the latest Windows version from theWindows x64 Installer link on the download website, e.g.,cmake-3.26.3-windows-x86_64.msi, and run the installer.

vcpkg

vcpkgis useful to install Windows tools without building them from source. Instructions to installvcpkgare:

C:>git clone https://github.com/microsoft/vcpkg
C:>vcpkg
C:>bootstrap-vcpkg.bat

(Optional) If using with Visual Studio run:

C:>vcpkg integrate install

Windows C++ Libraries

Various C++ libraries are required for the Linux build.

Berekley DB

Berkeley DB is an efficient, embedded non-SQL key-indexed database.

Download

The latest Berkeley DB version can be downloaded from:

  • https://www.oracle.com/database/technologies/related/berkeleydb-downloads.html
  • Select theDownloadlink under 'Berkeley DB version', e.g.,Berkeley DB 18.1 (18.1.40)
    • You may need to create an Oracle account.
  • On the next screen:
    • Check next to 'Oracle Berkeley DB version', e.g.,Oracle Berkeley DB 18.1.401
    • Select PlatformLinux x86-64
    • Accept the license agreements
    • SelectDownload
  • It will download a Windows executable named like 'Oracle_SSN_DLM_nnn.exe'
  • Run the executable, it will create a file named, e.g.,V997917-01.zip.
  • SelectOpen Destinationfrom the window that appears to find the zip.
  • Right-click the zip in File Explorer and selectExtract All...into a directory, e.g.,V997917-01.

LetBDB_HOMEbe the Berkeley DB installation directory inside the directory above, e.g.,db-18.1.40.

$ sudo apt update
$ sudo apt install autoconf
$ sudo apt install libtool
$ sudo apt install libssl-dev
$ sudo apt install libdb5.3-dev

Instructions to build are:

$ cd $BDB_HOME/build_unix
$ ../dist/configure <arguments>
$ make
$ sudo make install

configuretakes a few arguments. They are described at these files:

  • $BDB_HOME/docs/installation/build_unix_conf.html
  • $BDB_HOME/docs/installation/build_unix_flags.html

Useful ones include:

  • --prefix=directory determines the final installation directory, default is/usr/local
  • --enable-cxxto build the C++ library
  • --disable-sharedis useful to build with static rather than dynamic libraries
  • --enable-debug to build the library for debugging
  • CC=c compiler is the C compiler to use, e.g.,ccorgcc, default isgcc
  • CFLAGS=flags are the C compiler flags
  • CXXFLAGS=flags are the C++ compiler flags

A good set of commands to build Berkeley DB to install C++ and C static libraries under/usr/localare:

$ cd $BDB_HOME/build_unix
$ LDFLAGS="-R/usr/lib/x86_64-linux-gnu"
$ ../dist/configure --prefix=/usr --enable-cxx 
$ make
$ sudo make install

Windows installation

These are instructions to build Berkeley DB for Windows

  • Choose File -> Open -> Project/Solution.... and select the file %BDB_HOME%\build_windows\BDB_dotNet_vs2015.sln
  • Choose the desired project configuration from the drop-down menu on the tool bar (either Debug or Release).
  • Choose the desired platform configuration from the drop-down menu on the tool bar (usually Win32 or x64).
  • To build, right-click on the Berkeley_DB_vs2015 solution and select Build Solution.
  • The library files are in%BDB_HOME%\build_windows\x64\Debug:
    • libdb181d.dll
    • libdb181d.lib
  • The include files are in%BDB_HOME%

Json-c

You may installjcon-cfrom source or load it usingvcpkg. json-c json-c is a C-based JSON manipulation library.

Download

json-c can be downloaded by cloning the git repository:

$ git clone git@github.com:json-c/json-c.git

Let JSONC_HOME be the json-c installation directory.

Building from source

Steps to building on Windows are to .

  • Run these command in the Visual Studio command window using Tools->Command Line->Developer Command Prompt
$ cd %JSONC_HOME%
$ mkdir build
$ cd build
$ cmake ..
  • open the solutionbuild/json-c.slnin Visual Studio and build solution
  • library files are injson-c/build/Debug:
    • json-c-static.lib
    • json-c.lib
  • include files are injson-candjson-c/build

Installingjson-cusingvcpkg

The command to installjson-cusingvcpkgare:

C:>vcpkg  install json-c

Theexamplesdirectory has some C examples and instructions inexamples/README.allation These are instructions to prepare the Windows build environment.

$ git clone git@github.com:json-c/json-c.git

Let JSONC_HOME be the json-c installation directory.

  • Installingjson-cfrom source Steps to building on Windows from source are:
  • Run these command in the Visual Studio command window using Tools->Command Line->Developer Command Prompt
$ cd %JSONC_HOME%_
$ mkdir build
$ cd build
$ cmake ..
  • open the solutionbuild/json-c.slnin Visual Studio and build solution
  • library files are injson-c/build/Debug:
    • json-c-static.lib
    • json-c.lib
  • include files are injson-candjson-c/build