gpt4 book ai didi

c++ - 静态和共享库链接器错误

转载 作者:太空宇宙 更新时间:2023-11-04 11:56:22 25 4
gpt4 key购买 nike

我正在使用 NDK(Android 的原生编译器工具)。所以,情况是这样的:

Static boost → Shared helpers

Shared Game

Helpers 是一些用于游戏开发的共享库。 shared game 是一个由 java 代码包含的库(作为 native 库加载)。 Helpers lib 在内部使用了 boost,链接器在这里没问题。共享游戏通过 helpers api 使用 boost 但编译失败。

链接器无法解析 boost_system 库中的某些符号。所以,我这样做了:

Static boost → Shared helpers
| ↓
+----------- → Shared Game

现在可以正常编译了。怎么了?我想我可以将 boost once 链接到 helpers 并在共享游戏中使用它们。

最佳答案

没有错。正如你所说,你想要 shared game仅使用 shared helpers API由shared helpers导出动态库。你的错误是 shared game仍然依赖于一些裸露的 Boost API,这显然不是由 shared helpers 导出的.这就是为什么您必须将 Boost 显式链接到 shared game 的原因也是,以便正确解析这些 Boost 符号。

如果你想从 Boost API 中完全抽象出来并消除这种依赖性,那么你必须通过扩展 shared game 来包装这个 Boost API(你需要在 shared helpers 中) (当然不要忘记也从 shared helpers 导出这个包装 API)。

关于c++ - 静态和共享库链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15990760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com