Skip to content

Repository files navigation

C++ Bindings for Windows

Build JSR

Windows DLL for serial communication. It implements the cpp-core interface and provides functions for discovering, monitoring, opening, configuring, reading from, and writing to serial ports.

Requirements

  • Windows 10 or newer to run the DLL
  • CMake 3.30 or newer (4.3 or newer when building with clang-cl)
  • Git
  • A compiler with sufficient C++26 support
  • One of:
    • Windows with Visual Studio 2022 and the C++ workload
    • Linux with an x86-64 MinGW-w64 toolchain for cross-compilation

CMake downloads cpp-core v3.0.0 and GoogleTest automatically during configuration.

Build on Windows

git clone https://github.com/Serial-IO/cpp-bindings-windows.git
cd cpp-bindings-windows
cmake --preset windows-vs-release
cmake --build --preset windows-vs-release --config Release --target cpp_bindings_windows

The DLL is written below build/Release/.

Official release and JSR artifacts currently target x86_64-windows-msvc. Release DLLs statically include the MSVC runtime and expose the complete C API described by cpp-core 3.0.0.

Cross-compile with MinGW

The MinGW preset provides a local compile and link check from Linux:

cmake --preset windows-mingw-release
cmake --build --preset windows-mingw-release \
  --target cpp_bindings_windows cpp_bindings_windows_tests

The DLL and test executable are written to build/mingw/. The tests must be run on Windows (or in a compatible Windows runtime); cross-compilation alone does not execute them.

Tests

Build and run the C++ suite on Windows:

cmake --build --preset windows-vs-release --config Release --target cpp_bindings_windows_tests
ctest --test-dir build -C Release --output-on-failure

Tests that require a serial device use SERIAL_TEST_PORT and are skipped when no suitable device is available.

Serial port attach/detach callbacks use Windows Plug and Play notifications (CM_Register_Notification with GUID_DEVINTERFACE_COMPORT). Callbacks run on a dedicated dispatcher thread without polling. Existing ports are remembered when registering; only subsequent changes generate callbacks. A callback may replace or clear its own registration.

The optional Deno FFI smoke tests require Deno 2 and a built DLL:

cd integration_tests
deno task test

FFI metadata

Release and JSR packages include x86_64-windows-msvc API metadata generated from the public cpp-core headers with ASTrein 3.0.0, using the astrein_ffi_api schema version 3. It describes exported symbols, types, callbacks, default values, and API documentation for downstream FFI adapter generators.

License

This project is licensed under the GNU Lesser General Public License v3.0.

About

C++ Windows Bindings for the serial library

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages