0

Related: Combining several static libraries into one using CMake

When we use CMake to build a library add_library(example STATIC lib.c), we will get a libexample.a file. If we have the following dependency: target_link_libraries(example PUBLIC lib123) where lib123 is another library, then we must have libx installed on a computer to use libexample.a. Otherwise, if we do gcc main.c libexample.a the compiler will not be able to find symbols in lib123 required by functions in libexample.a.

The link above mentions how to merge these libraries manually. But when merging lib123, we realise that lib123 have a lot of other dependencies.

How to automatically resolve all dependencies and merge all of them to libexample.a?

Mr User
  • 205
  • 1
  • 5
  • "How to automatically resolve all dependencies" - Unlike to a *shared* library, a **static** library doesn't have dependency list embedded to it. You need to read list of static library dependencies from *somewhere* (e.g. from `pkg-config`) and pass that list to the merge tool. – Tsyvarev Apr 08 '23 at 09:04

0 Answers0