ccapi is a header-only C++ library. To use it in your C++ project, you must satisfy the following requirements and configuration steps:
Requirements
- C++ Standard: C++17 or higher.
- Dependencies:
- OpenSSL: Required for secure connections.
- Boost: Include directory should be
boost. - RapidJSON: Include directory should be
rapidjson/include. - hffix: Required only if using the FIX API.
- ZLIB: Required for market data on Huobi (and variants) or execution management on Huobi/Bitmart.
Configuration via Macros
You must define macros in your compiler command line to enable specific services and exchanges. These macros are located in include/ccapi_cpp/ccapi_session.h.
Service Enablement Macros:
CCAPI_ENABLE_SERVICE_MARKET_DATACCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENTCCAPI_ENABLE_SERVICE_FIX
Exchange Enablement Macros:
- Example:
CCAPI_ENABLE_EXCHANGE_BYBIT
Linking and Flags
- Libraries to link:
libssl and libcrypto (OpenSSL).ws2_32 (Windows only).
- Compiler Flags:
-pthread (GCC and MinGW).
Troubleshooting C++ Build
- OpenSSL not found: Set
OPENSSL_ROOT_DIR.- macOS:
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl (after brew install openssl). - Ubuntu:
sudo apt-get install libssl-dev. - Windows:
cmake -DOPENSSL_ROOT_DIR=C:/vcpkg/installed/x64-windows-static (after vcpkg install openssl:x64-windows).
- 'File too big' error: Add compiler flag
-Wa,-mbig-obj. - 'string table overflow' error: Add optimization flag
-O1 or -O2.
# Example of setting OpenSSL path for CMake
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..