To use dynamic libraries in a KasperskyOS-based solution, the following conditions must be met:
The KasperskyOS SDK comes with a separate toolchain for each supported processor architecture. A required toolchain may not support dynamic linking. To check whether dynamic linking is supported, you need to use the CMake
get_property()
command in the CMakeLists.txt
root file as follows:
get_property(CAN_SHARED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
if(CAN_SHARED)
message(STATUS "Dynamic linking is supported.")
endif()
-rdynamic
flag (with dynamic linking).If the toolchain supports dynamic linking, the CMake
initialize_platform()
command causes this flag to be used automatically for building all executable files defined via CMake
add_executable()
commands.
If the CMake
initialize_platform(FORCE_STATIC)
command is called in the CMakeLists.txt
root file, the toolchain supporting dynamic linking performs static linking of executable files.
The CMake
project_static_executable_header_default()
command affects the build of executable files defined via subsequent CMake
add_executable()
commands in one CMakeLists.txt
file. The toolchain that supports dynamic linking performs static linking of these executable files.
The CMake
platform_target_force_static()
command affects the build of one executable file defined via the CMake
add_executable()
command. The toolchain that supports dynamic linking performs static linking of this executable file.
The executable code of programs that is built with the -rdynamic
flag is linked to a static library if a dynamic library is not found. For example, if the CMake
target_link_libraries
(client -lm)
command is being used, the client
program is linked to the static library libm.a
if the dynamic library libm.so
is not found.