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
?