[英]Static and shared libraries linker error
I'm using NDK (native compiler tools for android). 我正在使用NDK(适用于Android的本地编译器工具)。 So, the situations looks like this:
因此,情况如下所示:
Static boost → Shared helpers
↓
Shared Game
Helpers
is some shared library for game developing. Helpers
是一些用于游戏开发的共享库。 shared game
is a library which is included by java code (loaded as native library). 共享
game
是一个包含在Java代码中的库(作为本机库加载)。 Helpers lib is using boost inside, the linker is fine here. 助手库正在内部使用boost,链接器在这里很好。 Shared game uses boost through helpers api but compilation fails.
共享游戏通过助手API使用Boost,但编译失败。
Linker can't resolve some symbols from boost_system library. 链接器无法解析boost_system库中的某些符号。 So, I did like this:
所以,我确实是这样的:
Static boost → Shared helpers
| ↓
+----------- → Shared Game
And now it compiles fine. 现在它可以编译了。 What's wrong?
怎么了? I thought that I can link boost once into helpers and use them inside shared game.
我以为我可以将一次Boost链接到助手中,并在共享游戏中使用它们。
Nothing is wrong. 没有错误。 As you said you want the
shared game
to use only shared helpers
API which is exported by shared helpers
dynamic library. 如您所说,您希望
shared game
仅使用shared helpers
API,该API由shared helpers
动态库导出。 Your mistake is that shared game
still relies on some bare Boost API which is obviously not exported by shared helpers
. 您的错误是,
shared game
仍然依赖一些裸露的Boost API,而这些API显然不是shared helpers
导出的。 That's why you have to link Boost explicitly to shared game
too, so that these Boost symbols are resolved properly. 这就是为什么您也必须将Boost显式链接到
shared game
,以便正确解析这些Boost符号。
If you want to fully abstract from Boost API and eliminate this dependency, then you'd have to wrap this Boost API (which you require in shared game
) by expanding shared helpers
(and of course don't forget to export this wrapped API from shared helpers
too). 如果您想完全从Boost API中抽象出来并消除这种依赖关系,那么您就必须通过扩展
shared helpers
来包装Boost API(在shared game
需要)(当然,不要忘记从中导出此包装的 API) shared helpers
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.