Compiling on Windows
This section provides instructions on how to compile dynamic-link library and executable files on Windows. We will employ two approaches, Visual Studio 2022 and MinGW.
With Visual Studio 2022
Compiling Shared Libraries
Prerequisites
Make sure you have an environment set up with:
git clone git@github.com:dolphindb/api-cplusplus.git
git checkout -b main origin/main
Compilation
cd path/to/api-cplusplus
mkdir build && cd build
cmake .. -G "Visual Studio 17 2022" -A x64 -DUSE_OPENSSL=1 -DOPENSSL_PATH=D:/temp/openssl-1.0.2l-vs2017 -DCMAKE_CONFIGURATION_TYPES="Release;Debug"
cmake --build . --config Release
Options for generating a project buildsystem:
Options for building a project:
Compiling Executable Files
(1) Copy the DolphinDBAPI.lib in the ../api-cplusplus/Release (generated in Compiling Shared Libraries) into the demo/lib directory.
(2) Run the following commands in PowerShell:
cd path/to/api-cplusplus/demo
mkdir build && cd build
cmake .. -G "Visual Studio 17 2022" -A x64 -DUSE_OPENSSL=1 -DOPENSSL_PATH=D:/temp/openssl-1.0.2l-vs2017 -DCMAKE_CONFIGURATION_TYPES="Release;Debug"
cmake --build . --config Release
The generated executable file apiDemo.exe is stored in the demo/bin/Release directory.
(3) Copy the following dynamic-link library to the demo/bin/Release directory.
- DolphinDBAPI.dll (located in ../api-cplusplus/Release)
- libeay32MD.dll (located in ../openssl-1.0.2l-vs2017/bin)
- ssleay32MD.dll (located in ../openssl-1.0.2l-vs2017/bin)
With MinGW
Compiling Shared Libraries
Prerequisites
Make sure you have an environment set up with:
Download the code from the api-cplusplus project in Github. Take the main branch as an example, run the following commands in Git Bash:
git clone git@github.com:dolphindb/api-cplusplus.git
git checkout -b main origin/main
Compilation
Execute the following commands in PowerShell to compile DolphinDBAPI.dll:
cd path/to/api-cplusplus
mkdir build && cd build
cmake .. -G "MinGW Makefiles" -DUSE_OPENSSL=1 -DOPENSSL_PATH=D:/workspace/testCode/api-cplusplus/lib/openssl-1.0.2u/openssl-1.0.2u/static
cmake --build .
Options for generating a project buildsystem:
Compiling Executable Files
(1) Copy the DolphinDBAPI.dll in the ../api-cplusplus/build(generated in Compiling Shared Libraries) into the demo/lib directory.
(2) Run the following commands in PowerShell:
cd path/to/api-cplusplus/demo
mkdir build && cd build
cmake .. -G "MinGW Makefiles" -DUSE_OPENSSL=1 -DOPENSSL_PATH=D:/workspace/testCode/api-cplusplus/lib/openssl-1.0.2u/openssl-1.0.2u/static
cmake --build .
The generated executable file apiDemo.exe is stored in the demo/bin directory.
(3) Copy the following dynamic-link libraries (compiled in [the above section]) to the demo/bin directory.
- DolphinDBAPI.dll (located in ../api-cplusplus/build)
- libeay32MD.dll (located in ../openssl-1.0.2u/static/bin)
- ssleay32MD.dll (located in ../openssl-1.0.2u/static/bin)