2

Assume I have a MVS solution with 3 projects. 2 of them are libraries and the third one is an exe. A.lib, B.lib, C.exe. A depends on B and C includes A and B, and we are all happy, the linker finds everything A needs from B when we include both in C.

I'm trying to replicate this with android ndk (using ndk-build), so the easiest way seemed to create 2 shared libs (A.so and B.so) and include them on a third C.so that then gets packed as a native activity in C.apk.

Apparently A.so won't build unless I include B.so in it's makefile. So instead of having

A.lib---> C.exe
B.lib--/

As I had in windows, I now need to have:

B.so --> A.so --> C.so

This gets pretty confusing as more libraries are added, because instead of resolving the linker symbols when adding the libs to the final apk, they need to be resolved in each lib. This behavior can be bypassed by using:

LOCAL_ALLOW_UNDEFINED_SYMBOLS=true

in the Android.mk of the libraries, but then when loading them into the application with

static 
{
 System.loadLibrary("B");
 System.loadLibrary("A");
}

it will fail at runtime saying A can't find some symbols (that are defined in B).

Is there a "correct" way of getting the individual libs to build allowing for undefined symbols and then making sure they find them when I include them all in the final project?

4

1 回答 1

0

事实证明,如果您将它们编译为静态库 (.a) 并使用该include $(PREBUILT_STATIC_LIBRARY)方法将它们包含在项目中,并在 LOCAL_WHOLE_STATIC_LIBRARIES := BA 中按依赖顺序列出它们

于 2013-11-25T23:01:30.960 回答