Reduce Library Binary Size for AVS Device SDK
You can use the following methods to reduce the size of the libraries you use in the Alexa Voice Service (AVS) Device SDK.
- Remove debug information from your binaries.
- Build the SDK with the
- Build and link static libraries.
Remove debug information
By default, binaries might contain debug information. This information is useful when analyzing dump files and troubleshooting application errors. However, this information is sometimes larger than the actual library code which occupies additional storage space.
To separate debug information from binaries, you can use the objcopy and strip utilities.
# Create a .debug file containing only debug information objcopy --only-keep-debug library.so library.so.debug # Remove debug information from original binary strip -g library.so # Add a link to debug information into stripped binary objcopy --add-gnu-debuglink=library.so.debug library.so
Build with MINSIZEREL
MINSIZEREL build option produces smaller binaries than the
RELEASE build. For more details about the SDK build options, see Build Type.
Build and link static libraries
The AVS Device SDK contains a large set of functions which you might not use in your application. If this is the case, you can build static libraries to reduce storage space and memory requirements. When you do this, the SDK drops any unused code that it doesn't use.
To use static libraries in the SDK
BUILD_SHARED_LIBS=OFF CMake parameters in your build.
The following example shows a full CMake build command on a Raspberry Pi, with shared libraries disabled.
cmake /home/pi/sdk-folder/sdk-source/avs-device-sdk \ -DGSTREAMER_MEDIA_PLAYER=ON \ -DPORTAUDIO=ON \ -DPKCS11=OFF \ -DPORTAUDIO_LIB_PATH=/home/pi/sdk-folder/third-party/portaudio/lib/.libs/libportaudio.a \ -DPORTAUDIO_INCLUDE_DIR=/home/pi/sdk-folder/third-party/portaudio/include -DCURL_INCLUDE_DIR=/home/pi/sdk-folder/third-party/curl-7.67.0/include/curl \ -DCURL_LIBRARY=/home/pi/sdk-folder/third-party/curl-7.67.0/lib/.libs/libcurl.so \ -DBUILD_SHARED_LIBS=OFF
Last updated: Sep 28, 2022