-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Description
Describe the bug
I want to link external static libraries to my app target. These external libraries were built with Conan and use Zephyr kernel functions. I made sure that the Conan build uses the same (generated) headers as the Zephyr build itself. I added the CMakeDeps generator path to the Zephyr build by adding a -DCMAKE_PREFIX_PATH argument so that I can use the find_package macros to discover the Conan imported library targets inside my Zephyr app CMakeLists. Now the problem is that when I do
find_package(conanlib1 CONFIG REQUIRED)
target_link_libraries(app conanlib1::conanlib1)
the Conan library always ends up after the zephyr/kernel/libkernel.a in the linker command line. That makes the linker drop the unused symbols from libkernel.a which are then reported as undefined symbols when linking conanlib1.
I already tried a myriad of things to get this running somehow, including trying to understand the zephyr cmake internals, but nothing seems to work. I found a suggestion to make the imported lib link against zephyr or zephyr_interface, but that didn't help either.
To Reproduce
You can reproduce this with the external_lib sample project. There the external lib is also added after the kernel lib on the command line.
Expected behavior
The external libs are placed after the whole-archive section but before libkernel.a.
Impact
Showstopper for our Conan/Zephyr integration project.
Logs and console output
n/a
Environment (please complete the following information):
- OS: Linux
- Zephyr 4.1.0-rc3, SDK 0.17.0
Additional context
n/a