This sample project requires several libraries, namely fmt, Boost.Beast, Boost.Asio, and OpenSSL. These can be installed easily through vcpkg.
# clone vcpkg if you do not already have it
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
# install required packages (example for 64-bit Linux)
./vcpkg/vcpkg install fmt boost-beast boost-asio openssl:x64-linuxWhen configuring CMake, use the vcpkg.cmake toolchain file:
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build buildAfter building, run the produced binary from the build directory:
./build/mainThe program connects to Binance's WebSocket trade stream and prints messages.
The get_mids target demonstrates using the header-only cpp-httplib
library. It performs a simple HTTP GET request to Binance's midPrice endpoint.
Build and run it from the build directory:
./build/get_mids