In the process of software development, it is sometimes necessary to generate dynamic library files based on static libraries.
When LD executes, the default will filter out unused functions in the static library, causing the generated dynamic library file to not contain all functions. So you need to configure the LD option--whole-archive.
Libsdk_api.a
SET (Src_sdk_api sdk_api.c)
add_library (Sdk_api STATIC ${src_sdk_api})
Libsdk_dev.a
SET (Src_sdk_dev sdk_dev.c)
add_library (Sdk_dev STATIC ${src_sdk_dev})
Libsdk_sys.a
SET (Src_sdk_sys sdk_memory.c)
add_library (Sdk_sys STATIC ${src_sdk_sys})
Libsdk.so
Add_subdirectory (API)
add_subdirectory (Dev)
add_subdirectory (SYS)
SET (src_sdk sdk_main.c) # Generating a dynamic library requires at least one source file
add_library (SDK SHARED ${src_sdk})
target_link_libraries (SDK
"-wl,--whole-archive" # The following libraries use the--whole-archive option
sdk_api
sdk_dev
sdk_sys
"-wl,--no-whole-archive") # The following libraries do not use the--whole-archive option