I have a collection of libfooi.a; libfoo1.a, libfoo2.a, libfoo3.a ... that using factories (with static code) have a common interface to create C++ objects.
With CMake I choose one of them, and create a libfooWrapper.a that link it and add all content. Using CMake this CMakeLists.txt works in Android:
PROJECT(fooWrapper)
INCLUDE_DIRECTORIES(___)
ADD_LIBRARY(fooWrapper SHARED ${SRC} ${HEADERS} ) # Must be STATIC in iOS
IF(selected1)
TARGET_LINK_LIBRARIES(fooWrapper -Wl,--whole-archive foo1 -Wl,--no-whole-archive)
ELSEIF(...)
TARGET_LINK_LIBRARIES(fooWrapper -Wl,--whole-archive foo2 -Wl,--no-whole-archive)
A executable app project created manually, just link generated fooWrapper and work.
But in iOS using Clang, I have changed ADD_LIBRARY to STATIC, and try using -Wl,--whole-archive but doesnt work. I have checked the documentation of that using -Obj -Wl,-force_load must work. I have tried too using flag -Obj -Wl,-all_load.
Analysing library libfooWrapper.a with otool, it seems that all content from libfooi.a is no added into libfooWrapper.a, but I need to put it inside to avoid change manually flags in executable app project.
What is wrong with linking?