A unified dependency management method and system based on C++ SDK
By building a unified dependency layer in the C++ SDK, the problem of inconsistent dependency management in the basic software of spaceborne computers was solved, achieving version consistency and build reproducibility between projects, and improving development efficiency and system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG LAB
- Filing Date
- 2026-03-17
- Publication Date
- 2026-06-19
AI Technical Summary
In the development of basic software for spaceborne computers, existing technologies suffer from problems such as inconsistent versions due to decentralized management, difficulty in troubleshooting dependency conflicts, unreproducible builds, difficulty in upgrading third-party libraries, and lack of a unified interface layer, resulting in ABI incompatibility, symbol conflicts, and unstable build results.
By building a unified dependency layer in the C++ SDK, using interface library targets to encapsulate third-party dependencies, uniformly downloading and building third-party libraries, defining version information, and automatically passing build attributes through an attribute propagation mechanism, a unified interface layer and basic capability modules are provided to achieve automated and consistent dependency management.
This enabled all projects to use the same version of dependencies, eliminating symbol conflicts and ABI incompatibility, ensuring consistent build results, reducing management costs, improving development efficiency and system stability, and guaranteeing interface consistency and build reproducibility within the team.
Smart Images

Figure CN121858153B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of software engineering and construction system management technology, and particularly relates to a unified dependency management method and system for C++ projects. It is especially suitable for enterprise-level R&D environments with shared public dependency libraries for basic software of spaceborne computers, and specifically relates to a unified dependency management method and system based on C++ SDK. Background Technology
[0002] In the development team of basic software for spaceborne computers, the basic software usually includes multiple functional modules such as telemetry and control data transmission, process management, equipment management, file management, redundancy recovery, and status monitoring. Multiple projects usually rely on the same basic third-party libraries, such as log library (spdlog), formatting library (fmt), JSON parsing library (nlohmann_json), and Redis client library (hiredis).
[0003] The following problems exist in the existing technology:
[0004] 1. Dependency on distributed management leads to version inconsistencies.
[0005] Each project downloads or installs its own third-party dependencies, and inconsistent versions can lead to problems such as ABI incompatibility, linking failures, and runtime crashes.
[0006] 2. Dependency conflicts are difficult to troubleshoot.
[0007] When project A uses fmt v8 and project B uses fmt v9, ODR (One Definition Rule) conflicts and symbol conflicts may occur when multiple modules are linked into the same executable file.
[0008] 3. Constructing a non-reproducible system
[0009] Developers compile dependencies themselves and install them from different sources, which makes the build results unstable.
[0010] 4. Difficulty in upgrading third-party libraries
[0011] Upgrading each project individually would be a huge undertaking and could easily break compatibility.
[0012] 5. Lack of a unified interface layer
[0013] The inability to guarantee consistent basic capabilities such as logging API, database API, and serialization API across teams leads to inconsistent behavior across different projects.
[0014] Therefore, a systematic solution that can automatically propagate dependency configurations is needed to ensure consistent dependencies across all projects within the team, reproducible builds, and strictly unified interfaces. Summary of the Invention
[0015] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a unified dependency management method and system based on C++ SDK.
[0016] The objective of this invention is achieved through the following technical solution: a unified dependency management method based on a C++ SDK. This method is applied to the C++ SDK and, by building a unified dependency layer within the SDK, enables multiple projects to automatically inherit unified dependency versions, build parameters, and interface behaviors. The method includes the following steps:
[0017] Create an interface library target to encapsulate third-party dependencies. The interface library target includes the include path, compilation options, macro definitions, and link attributes of the third-party libraries.
[0018] During the SDK build phase, third-party libraries are downloaded and built uniformly through a dependency retrieval mechanism to obtain a unified version of the dependency library files;
[0019] At the SDK project level, define the version information of third-party libraries to ensure that all projects that reference this SDK use the same version of the dependency library files;
[0020] Based on the attribute propagation mechanism of the interface library target, the build attributes of the third-party library (including path, compilation options and link attributes, etc.) are automatically passed to any project that depends on the SDK;
[0021] When users build a project, by introducing the interface library target, they can automatically obtain the same version of third-party dependencies and their build properties without having to configure them repeatedly.
[0022] Furthermore, the target of the interface library is defined through the INTERFACE type of CMake, so that the SDK itself can propagate dependency information without compilation.
[0023] Furthermore, the dependency fetching mechanism is either FetchContent or ExternalProject, and a unified version locking mechanism is used to ensure that the build is reproducible.
[0024] Furthermore, the SDK includes: automatically detecting version information of third-party dependencies introduced in external projects, and blocking the build when a conflict is detected.
[0025] Furthermore, the SDK is also used to generate a unified configuration header file for synchronizing build options, version numbers, or macro definitions across projects.
[0026] Furthermore, the SDK also provides various basic capability modules, including a log interface layer, a database interface layer, a serialization interface layer, and a unique identifier generator, which are exposed to upper-layer projects through a unified interface.
[0027] Furthermore, the user's project building process includes: if multiple projects are built, they are connected to the SDK through target_link_libraries, automatically inheriting all dependency configurations to achieve zero-configuration integration.
[0028] This invention also provides a unified dependency management system based on a C++ SDK, including:
[0029] An interface library target creation module is used to create interface library targets, which are used to encapsulate third-party dependencies. The interface library target includes the include path, compilation options and link attributes of the third-party libraries.
[0030] The dependency build module is used to download and build third-party libraries uniformly during the SDK build phase through a dependency retrieval mechanism, thereby obtaining a unified version of the dependency library files;
[0031] The dependency unification module is used to define the version information of third-party libraries, ensuring that all projects that reference this SDK use the same version of the dependency library files;
[0032] The user interaction module is used to import the interface library target according to the user's instructions during the project building process, and automatically obtain the same version of third-party dependencies and their build attributes without repeated configuration.
[0033] The present invention also provides an electronic device, including a memory and a processor, wherein the memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the unified dependency management method based on the C++ SDK.
[0034] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the unified dependency management method based on the C++ SDK.
[0035] The present invention has the following beneficial effects:
[0036] 1. Eliminate dependency version inconsistencies: All projects must use the same version of dependencies to avoid symbol conflicts and ABI incompatibility.
[0037] 2. Completely reproducible build: The dependency sources are stable, and the build results are consistent.
[0038] 3. Significantly reduce dependency management costs: Upgrading dependencies only requires modifying one part of the SDK.
[0039] 4. Improve team development efficiency: Projects do not need to worry about third-party dependency management, only need to link the SDK.
[0040] 5. Improve system stability: All modules use consistent basic capabilities such as logging, serialization, and database.
[0041] 6. The overall architecture is easier to maintain and expand. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is a schematic diagram of the process of the present invention;
[0044] Figure 2 This is a schematic diagram of the system of the present invention. Detailed Implementation
[0045] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The singular forms “a,” “the,” and “the” used in this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0046] It should be understood that although the terms first, second, third, etc., may be used in this invention to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of this invention, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0047] The present invention will now be described in detail with reference to the accompanying drawings. Unless otherwise specified, the features of the following embodiments and implementations can be combined with each other.
[0048] like Figure 1As shown, this embodiment of the invention provides a unified dependency management method based on a C++ SDK. The method is applied to the C++ SDK and, by building a unified dependency layer within the SDK, enables multiple projects to automatically inherit unified dependency versions, build parameters, and interface behaviors. The method includes the following steps:
[0049] Create an interface library target to encapsulate third-party dependencies. The interface library target includes the include path, compilation options, macro definitions, and link attributes of the third-party libraries.
[0050] During the SDK build phase, third-party libraries are downloaded and built uniformly through a dependency retrieval mechanism to obtain a unified version of the dependency library files; wherein the dependency retrieval mechanism is FetchContent or ExternalProject, and a unified version locking mechanism is used to ensure that the build is reproducible.
[0051] At the SDK project level, define the version information of third-party libraries to ensure that all projects that reference this SDK use the same version of the dependency library files.
[0052] Based on the attribute propagation mechanism of the interface library target, the build attributes of the third-party library (including path, compilation options and link attributes, etc.) are automatically passed to any project that depends on the SDK.
[0053] When a user builds a project, by introducing the interface library target, the user can automatically obtain third-party dependencies and their build attributes with the same version, without having to configure them repeatedly. When building multiple projects, the user can connect to the SDK through target_link_libraries and automatically inherit all dependency configurations to achieve zero-configuration integration.
[0054] The interface library target is defined through the INTERFACE type of CMake, so that the SDK itself can propagate dependency information without compilation.
[0055] Preferably, the constructed SDK also has the following functions:
[0056] The SDK automatically detects the version information of third-party dependencies introduced in external projects and blocks the build when a conflict is detected.
[0057] The SDK generates a unified configuration header file, which is used to synchronize build options, version numbers, or macro definitions across projects.
[0058] The SDK also provides various basic capability modules, including a log interface layer, a database interface layer, a serialization interface layer, and a unique identifier generator, which are exposed to upper-layer projects through a unified interface.
[0059] like Figure 2 As shown, this embodiment of the invention also provides a unified dependency management system based on a C++ SDK, including:
[0060] The interface library target creation module is used to create interface library targets, which are used to encapsulate third-party dependencies. The interface library target includes the include path, compilation options, and link attributes of the third-party library. The attributes in the interface library target contain attribute propagation information, which automatically passes the build attributes of the third-party library to any project that depends on the SDK.
[0061] The dependency build module is used to download and build third-party libraries uniformly during the SDK build phase through a dependency retrieval mechanism, thereby obtaining a unified version of the dependency library files.
[0062] The dependency unification module is used to define the version information of third-party libraries, ensuring that all projects that reference this SDK use the same version of the dependency library files.
[0063] The user interaction module is used to import the interface library target according to the user's instructions during the project building process, and automatically obtain the same version of third-party dependencies and their build configurations without the need for repeated configuration.
[0064] To verify the feasibility of the present invention, the following three specific embodiments are provided to realize the functions of the present invention.
[0065] Example 1: Unified C++ SDK Architecture Design
[0066] This embodiment provides a unified C++ SDK architecture for multiple projects. The SDK, as the core component for unified dependency management, has the following main structure:
[0067] 1. Dependency Builder Subsystem
[0068] 1.1. Responsible for uniformly acquiring third-party dependencies, such as spdlog, fmt, hiredis, nlohmann_json, etc.
[0069] 1.2. Use CMake's FetchContent module to pull the source code. Example configuration:
[0070] FetchContent_Declare(
[0071] fmt
[0072] GIT_REPOSITORY https: / / xxx.xxx / xxx / xxx.git
[0073] GIT_TAG 9.1.0 )
[0075] FetchContent_MakeAvailable(fmt)
[0076] 1.3. The version of each dependency is managed uniformly by the sdk_versions.cmake file.
[0077] 2. Interface Library Target (INTERFACE Library) Construction Subsystem
[0078] The SDK creates a library target of type INTERFACE, for example:
[0079] CMake
[0080] add_library(company_cxx_sdk INTERFACE)
[0081] target_link_libraries(company_cxx_sdk INTERFACE spdlog::spdlog fmt::fmt nlohmann_json::nlohmann_json hiredis)
[0082] This library does not produce binary files, but it does carry a complete dependency chain, compilation parameters, and macro definitions.
[0083] 3. Interface layer capability module (unified encapsulation of basic capabilities)
[0084] The SDK encapsulates cross-project functionality, including:
[0085] 3.1. Logging capabilities: Unified encapsulation of spdlog, providing relevant macro definitions to directly print logs.
[0086] 3.2. Redis capabilities: Encapsulate hiredis, providing a unified connection pool interface as well as related operations and entry points.
[0087] 3.3. UUID generation capability: Provides a thread-safe UUID utility class, supporting UUID generation and automatic propagation through middleware.
[0088] 3.4. JSON utility class: Provides a unified wrapper for nlohmann_json to maintain consistent API specifications.
[0089] All of the above modules are provided in header-only or interface format to ensure automatic propagation capability.
[0090] 4. Unified configuration header file generation
[0091] The SDK automatically generates a configuration file, for example: config / sdk_config.h.
[0092] This includes: SDK version number, build mode, dependency library version, and feature switch macros.
[0093] Ensure that all projects behave consistently during build.
[0094] Example 2: Project Integration and Automatic Dependency Propagation Process
[0095] The following describes how external C++ projects can integrate the SDK without manually configuring dependencies.
[0096] 1. Use FetchContent to download and compile the SDK source code.
[0097] CMake
[0098] FetchContent_Declare(
[0099] company_cxx_sdk
[0100] GIT_REPOSITORY https: / / xxx.xxx / xxx / xxx.git
[0101] GIT_TAG 7bdf23a # Version hash lock )
[0103] FetchContent_MakeAvailable(company_cxx_sdk)
[0104] 2. The project only requires one line to inherit all dependencies.
[0105] CMake
[0106] target_link_libraries(my_project PRIVATE company_cxx_sdk)
[0107] 3. Dependency chain automatic propagation process
[0108] 3.1. When CMake processes the interface target, it automatically passes the following attributes to my_project:
[0109] INTERFACE_INCLUDE_DIRECTORIES;
[0110] INTERFACE_LINK_LIBRARIES;
[0111] INTERFACE_COMPILE_DEFINITIONS;
[0112] INTERFACE_COMPILE_OPTIONS.
[0113] 3.2. Therefore, external projects do not need to care about the versions and installation paths of dependencies such as spdlog, fmt, hiredis, and JSON.
[0114] 4. The construction results are completely reproducible.
[0115] 4.1. The SDK uses Git TAG / commit hash to lock dependency versions;
[0116] 4.2. The source code of each dependency is controlled by the SDK;
[0117] 4.3. Installation does not require the system package manager and is unaffected by changes in the system environment;
[0118] 4.4. The team members, CI / CD environment, and production environment setup results are completely consistent.
[0119] Example 3: Dependency Upgrade Process
[0120] A unified dependency management solution makes dependency upgrades controllable and orderly.
[0121] Modify the new version of the dependency in the SDK:
[0122] set(FMT_VERSION "10.0.0")
[0123] The SDK tests the compatibility of all interface modules.
[0124] Tag: v2.3.0
[0125] External projects only need to update the SDK tags:
[0126] GIT_TAG v2.3.0
[0127] There is no need to modify dependencies for each project, and there will be no version confusion.
[0128] This invention also provides an electronic device, including a memory and a processor, wherein the memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the unified dependency management method based on C++ SDK as described in any embodiment.
[0129] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the unified dependency management method based on C++ SDK as described in any embodiment.
[0130] The computer-readable storage medium can be an internal storage unit of any data processing device described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be any data processing device, such as a plug-in hard disk, smart media card (SMC), SD card, flash card, etc., equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units of any data processing device and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the data processing device, and can also be used to temporarily store data that has been output or will be output.
[0131] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only.
[0132] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A unified dependency management method based on C++ SDK, characterized in that, The method is applied to the C++ SDK and includes the following steps: Create an interface library target to encapsulate third-party dependencies. This target includes the include path, compilation options, macro definitions, and link attributes for the third-party libraries. The interface library target is defined using CMake's INTERFACE type, allowing the SDK itself to propagate dependency information without compilation. During the SDK build phase, third-party libraries are downloaded and built uniformly through a dependency retrieval mechanism to obtain a unified version of the dependency library files; At the SDK project level, version information of third-party libraries is defined to ensure that all projects referencing the SDK use the same version of the dependency library files. The SDK includes: automatically detecting the version information of third-party dependencies introduced in external projects and blocking the build when conflicts are detected; automatically generating a unified configuration header file for synchronizing build options, version numbers, or macro definitions across projects; the SDK also provides various basic capability modules, including a log interface layer, a database interface layer, a serialization interface layer, and a unique identifier generator, and exposes them to upper-layer projects through a unified interface. Based on the attribute propagation mechanism of the interface library target, the build attributes of the third-party library are automatically passed to any project that depends on the SDK; When a user builds a project, by introducing the interface library target, the user can automatically obtain third-party dependencies and their build attributes with the same version without repeated configuration. This includes: if multiple projects are built, the SDK is connected through target_link_libraries, and all dependency configurations are automatically inherited to achieve zero-configuration integration.
2. The method of claim 1, wherein, The dependency retrieval mechanism is either FetchContent or ExternalProject, and a unified version locking mechanism is used to ensure that the build is reproducible.
3. A unified dependency management system based on C++ SDK, characterized in that, include: The interface library target creation module is used to create interface library targets. These targets encapsulate third-party dependencies and include the include path, compilation options, macro definitions, and link attributes of the third-party libraries. The interface library targets are defined using CMake's INTERFACE type, allowing the SDK itself to propagate dependency information without compilation. The dependency build module is used to uniformly download and build third-party libraries during the SDK's build phase through a dependency retrieval mechanism, obtaining a unified version of the dependency library files. The SDK includes: automatically detecting the version information of third-party dependencies introduced in external projects and blocking the build when conflicts are detected; automatically generating a unified configuration header file for synchronizing build options, version numbers, or macro definitions across projects; the SDK also provides various basic capability modules, including a log interface layer, a database interface layer, a serialization interface layer, and a unique identifier generator, which are exposed to upper-layer projects through a unified interface. The dependency unification module is used to define the version information of third-party libraries, ensuring that all projects that reference this SDK use the same version of the dependency library files; The user interaction module is used to import the interface library target according to the user's instructions during the project building process, and automatically obtain the same version of third-party dependencies and their build attributes without repeated configuration. This includes: if multiple projects are built, they are connected to the SDK through target_link_libraries, and all dependency configurations are automatically inherited to achieve zero-configuration integration.
4. An electronic device comprising a memory and a processor, characterized in that, The memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the unified dependency management method based on C++ SDK as described in any one of claims 1-2.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the unified dependency management method based on the C++ SDK as described in any one of claims 1-2.