# Expressing runtime dependencies in INTERFACE\_LINK\_LIBRARIES

**URL:** <https://discourse.cmake.org/t/expressing-runtime-dependencies-in-interface-link-libraries/10934>\
**Category:** Code\
**Created:** [June 3, 2024, 1:49pm UTC](https://discourse.cmake.org/t/expressing-runtime-dependencies-in-interface-link-libraries/10934 "2024-06-03T13:49:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![emaschino](https://discourse.cmake.org/user_avatar/discourse.cmake.org/emaschino/32/6126_2.png) [@emaschino](https://discourse.cmake.org/u/emaschino)\
**Post date:** [June 3, 2024, 1:49pm UTC](https://discourse.cmake.org/t/expressing-runtime-dependencies-in-interface-link-libraries/10934/1 "2024-06-03T13:49:57Z")

</div>

Hi,

I don’t know how this is specific to Android development, but here it is.

For Android Studio to properly pack in an .apk file the runtime dependencies (the .so libraries) of an exported target (being a shared library or an application), I’ve discovered that they must be listed in the target `INTERFACE_LINK_LIBRARIES` (direct or transitively inherited). Otherwise, they’re not added to the final APK, resulting in a crash at application startup. I know for sure that Android Studio (probably the Android Gradle Plugin underneath) doesn’t rely on `file(GET_RUNTIME_DEPENDENCIES)`, or `TARGET_RUNTIME_DLLS` genex to get/pack the runtime dependencies ([Google Issue Tracker](https://issuetracker.google.com/issues/274493986)). So, I was just wondering how is it correct/nonsense to express a target runtime dependencies as `INTERFACE_LINK_LIBRARIES`?

Doing so has consequences. In order to populate a target `INTERFACE_LINK_LIBRARIES`, the dependencies must be added with `target_link_libraries(... PUBLIC ...)`, even for _e.g._ implementation-only dependencies. Otherwise, they’ll be added to the target `IMPORTED_LINK_DEPENDENT_LIBRARIES` property and won’t be part of the APK. For a shared library, declaring all its dependencies as PUBLIC will then requires that all its targets are exported, thus requiring that the exported config file package has `find_dependencies()` for all the dependencies (_e.g._ OpenCV modules built as separate .so files), although this isn’t strictly necessary from the build point of view.

Is this an Android-specific workaround to make Android Studio happy or a generic and comprehensive approach?

Thanks.
