Compiling on Linux
This section provides instructions on how to compile shared objects and executable files on Linux. We will use RedHat as an example.
Compiling Shared Libraries
Prerequisites
Make sure you have an environment set up with:
yum install openssl-devel
yum install libuuid-devel
Download the code from the api-cplusplus project in Github. Take the main branch as an example, run the following commands in terminal:
git clone git@github.com:dolphindb/api-cplusplus.git
git checkout -b main origin/main
Compilation
Execute the following commands in terminal to compile libDolphinDBAPI.so:
cd path/to/api-cplusplus
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_AERON=OFF -DUSE_OPENSSL=ON
make -j4
Description of cmake parameters:
Compiling Executable Files
- Copy the DolphinDBAPI.so in the ../api-cplusplus/build (generated in Compiling Shared Libraries) into the demo/lib directory.
- Run the following commands in
terminal:
cd path/to/api-cplusplus/demo mkdir build && cd build cmake .. -DABI=0 -DUSE_OPENSSL=1 -DOPENSSL_PATH=/home/openssl/ cmake --build .Description of cmake parameters:
- -DABI=0: Specifies the value of _GLIBCXX_USE_CXX11_ABI during compilation. It can be set to 1 or 0. Note that the value of ABI must be the same.
- -DUSE_OPENSSL=1: This parameter must be specified if you want to use OpenSSL to encrypt the communication between the API and DolphinDB. When specified, the SSL and Crypto dynamic libraries will be linked when compiling the API dynamic library.
- -DOPENSSL_PATH=/path/to/openssl: If OpenSSL is not installed on the system, you can specify the OpenSSL path using this parameter.
- The generated executable file apiDemo is stored in the demo/bin directory.
