Skip to content

Fix build issues in C and add CMake support.#677

Merged
GyuH13 merged 9 commits into
mainfrom
feature-use-cmake
Apr 2, 2026
Merged

Fix build issues in C and add CMake support.#677
GyuH13 merged 9 commits into
mainfrom
feature-use-cmake

Conversation

@GyuH13

@GyuH13 GyuH13 commented Mar 27, 2026

Copy link
Copy Markdown
Member

This PR fixes a build issue in the C SDK and introduces CMake support.

Changes

1. Fix Windows Build Issue

In port_handler.h, the following variables were declared as extern:

  • int g_used_port_num
  • uint8_t *g_is_using

However, these variables were only defined under the Linux implementation in port_handler.c, which caused build failures on Windows.
This PR adds the missing definitions for Windows to resolve the issue.


2. Introduce CMake Support

CMake support has been added to unify the build system.

  • Previously, the build system was separated by operating system and architecture (bit).
  • This has now been consolidated into a single CMake-based build system.
  • The installed SDK can now be used via find_package() in CMake.

3. Deprecation Plan for Legacy Make System

The existing Make-based build system will be kept temporarily for compatibility.

  • It will remain during a transition period.
  • It is planned to be removed after approximately 3 months.

4. Installation Path Changes (C vs C++)

Previously, when installing the C SDK via the Make system, files were installed under:

/usr/local/include/dynamixel_sdk/*

Since this path is shared between C and C++ SDKs, it can cause ambiguity.

To address this:

  • The CMake build for the C SDK now uses a distinct prefix and project name:

    • dynamixel_sdk_c

This ensures clear separation between C and C++ installations and avoids conflicts.


Summary

  • Fixed Windows build issue due to missing global variable definitions
  • Added unified CMake build support
  • Enabled usage via find_package()
  • Introduced a clear separation between C and C++ SDK installations
  • Planned deprecation of legacy Make build system

Thank you.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Dynamixel SDK to version 4.0.4 and introduces a unified CMake build system for the C and C++ libraries, including installation and uninstallation scripts. Feedback identifies a regex error in the C SDK's uninstallation logic and suggests refining the C++ SDK's exported include directories to simplify consumer header inclusion. Additionally, a refactor is recommended for port_handler.c to consolidate global variable definitions and reduce platform-specific code duplication.

Comment thread c/cmake/cmake_uninstall.cmake.in Outdated
Comment thread c++/CMakeLists.txt
Comment thread c++/example/dxl_monitor/CMakeLists.txt Outdated
Comment thread c++/example/protocol1.0/CMakeLists.txt Outdated
Comment thread c++/example/protocol2.0/CMakeLists.txt Outdated
Comment thread c++/example/protocol_combined/CMakeLists.txt Outdated
Comment thread c/src/dynamixel_sdk/port_handler.c
@GyuH13
GyuH13 requested review from nhw-robotis and sunghowoo March 30, 2026 04:08
@GyuH13 GyuH13 self-assigned this Mar 30, 2026
@GyuH13 GyuH13 added the enhancement New feature or request label Mar 30, 2026
@GyuH13 GyuH13 added this to Platform Mar 30, 2026
@GyuH13 GyuH13 moved this to 📝 Pull Request in Platform Mar 30, 2026

@nhw-robotis nhw-robotis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GOOD

@sunghowoo sunghowoo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GyuH13
GyuH13 merged commit aaed3b5 into main Apr 2, 2026
3 checks passed
@GyuH13
GyuH13 deleted the feature-use-cmake branch April 2, 2026 06:27
This was referenced Apr 2, 2026
@robotpilot robotpilot moved this from 📝 Pull Request to 🚩Done in Platform May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants