gpt4 book ai didi

android - 为什么使用NDK无法存在不同的STL实现?

转载 作者:行者123 更新时间:2023-12-03 07:23:30 24 4
gpt4 key购买 nike

我尝试基于两个开源库构建一个项目。我正在使用的库是OpenCV和ceres。 libopencv_java3.so是来自github网站的发行版OpenCV3.1.2,其中包括OpenCV-3.1.0-android-sdk。 libceres.so由我自己从源代码编译而来。

当我构建应用程序时,NDK-build会生成以下信息:

clang++.exe: warning: argument unused during compilation: '-nostdlib++' [-Wunused-command-line-argument]

error: undefined reference to 'cv::imwrite(cv::String const&, cv::_InputArray const&, std::__ndk1::vector > const&)'



谷歌搜索后,我发现了一篇相关文章

Error Undefined reference to 'std::__ndk1::locale::~locale()'
答案说,使用了不同的STL实现。

就我而言,libopencv_java.so可以使用gnuSTL_static,而libceres使用c++ _ static。
我不明白原因。这两种实现都是静态库,不应发生冲突。
  • 用gnuSTL_static编译来自opencv发行版的所有文件吗?
  • 为什么__ndk1出现在std::vector中?
  • 对于一个大型项目,不同的工程师承担不同的子任务。他们应该链接一个通用的STL实现吗?静态链接和动态链接的要求是否不同?
  • 最佳答案

    这个答案来晚了,但是我希望它可以帮助遇到类似问题的人(像我一样)。

    Is all so files from opencv release compiled with gnustl_static?


    看来OpenCV 3.X-android(甚至在撰写本文时,是最新的3.4.12)都使用 gnustl_statc。这意味着所有STL组件都位于命名空间 std中。
    但是对于OpenCV 4.X-android,该库已使用 c++_static进行编译,因此STL组件位于 namespace std::__ndk1中。

    Why __ndk1 appears in std::vector?


    它是 inline namespace

    For one large project, different engineers take different sub-tasks. Should they link one common stl implementation? Is the requirement different for static linkage and dynamic linkage?


    不确定...

    关于android - 为什么使用NDK无法存在不同的STL实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60187193/

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