Recommendation for zephyr project setup with multiple libraries #93579
Replies: 2 comments 1 reply
-
I assume your library is located in a Git repository? Let west check out this library; then west will find your library during compilation. |
Beta Was this translation helpful? Give feedback.
-
No, this is not supported, the point in static libraries is you build a static library that has no relation to zephyr then use it from within zephyr, not build zephyr with static libraries then use said static libraries in other zephyr (or non-zephyr) projects, the latter is a complete minefield full of pitfalls that if you think is a good idea, you do not understand how zephyr or the build system works (because it is not, you can experiment with this by setting a Kconfig, building a "static library" then including said static library with an application with a different value for the same Kconfig, the library is inherently broken/faulty/deficient by design) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm relatively new to Zephyr and currently exploring the best project setup for our needs. Our previous project was structured using CMake, with multiple folders and CMakeLists.txt files, each containing
add_library(mylib INTERFACE)
oradd_library(mylib STATIC)
statements. Here's an example of our structure:We use libraries to organize our software into smaller, manageable parts, which are then provided to users for linking to their applications. Each library has a limited scope, containing only the necessary compile definitions and include directories.
As we transition to Zephyr, we aim to maintain this modular structure. We want users to include our software as a single Zephyr module composed of multiple libraries. Technically, using
zephyr_library_named
to create static libraries that users can link to their applications seems feasible. In contrast to this, combining everything into one library results in an overly complexcompile_commands.json
file, with unnecessary flags for each compilation unit.We've started creating a sample app using
zephyr_library_named
in its CMakeLists.txt. Unfortunately, we encounter warnings such as:Could you advise on how to avoid these warnings? Will they disappear once we move all
zephyr_library_named
entries into a separate Zephyr module that we then consume in our sample app? Any further recommendations for us?Thank you for your assistance!
Beta Was this translation helpful? Give feedback.
All reactions