我们有一个项目,该项目使用了一个在Google的 Bazel 构建系统。
该项目本身是一个Android Native库,它是使用gradle with cmake构建的,
externalNativeBuild {
cmake {
cppFlags "-std=c++17 -fopenmp -static-openmp -fexceptions -frtti -Wl,-s -Wno-unused-command-line-argument"
arguments "-DANDROID_STL=c++_shared", "-DOpenCV_DIR=${opencvDir}", "-DANDROID_ARM_NEON=TRUE"
}
}
因此我们最终获得了2个(或以后,也取决于OpenCV)共享对象库 - 实际 sdk
& MediaPipe
项目。
我们看到的问题类似于 this 进入我们项目的运行时部分。
E/libc++abi: terminating with uncaught exception of type std::bad_cast: std::bad_cast
我看到 this 这在该问题线程上发表评论,并添加
System.loadLibrary("c++_shared");
求解的解决方案坠机。
但是,这不是一个实用的解决方案,因为我们正在构建的项目将以多个 .so
文件的形式提供本机SDK,我不想强迫我们的客户明确加载在使用我们的库之前,共享运行时库。
gradle库具有“ -dandroid_stl = c ++ _共享”
flag,所以这是在使用共享的标志,但是我找不到任何使用 c来编译MediaPipe(使用Bazel)的方法++ _共享
。我找不到任何引用在编译Bazel项目时使用共享运行时的引用(除 this , which isn't exactly relevant and the solution didn't help me)
We might be able to work around this by setting -DANDROID_STL=c++_static
, but this has other issues, mainly,它违反 android的指南对于中间件
商
- 供应 使用
c ++ _共享
android stl构建MediaPipe(或任何其他基于Bazel的),
- 如果没有,是否有其他选项可以解决运行时冲突,
- 甚至是运行时冲突还是其他选择?
We have a project that uses a library that is built on top of Google's Mediapipe, which is built using the Bazel
build system.
The project itself is an Android Native Library, built using Gradle with CMake
externalNativeBuild {
cmake {
cppFlags "-std=c++17 -fopenmp -static-openmp -fexceptions -frtti -Wl,-s -Wno-unused-command-line-argument"
arguments "-DANDROID_STL=c++_shared", "-DOpenCV_DIR=${opencvDir}", "-DANDROID_ARM_NEON=TRUE"
}
}
So we end up with 2 (or more later, also dependent on OpenCV for example) shared object libraries - the actual SDK
& the Mediapipe
project.
We're seeing issues that are similar to this, which lead me to look into the runtime part of our project.
E/libc++abi: terminating with uncaught exception of type std::bad_cast: std::bad_cast
I saw this comment on that issue thread, and adding
System.loadLibrary("c++_shared");
Solved the crash.
However, this is not a practical solution as the project we're building would provide a native SDK in the form of multiple .so
files and I wouldn't want to force our clients to have to explicitly load the shared runtime library before using our library.
The gradle library has "-DANDROID_STL=c++_shared"
flag, so this is using the shared one, but I couldn't find any way to compile Mediapipe (with Bazel) using c++_shared
. I couldn't find any reference to using shared runtime when compiling Bazel projects (except for this, which isn't exactly relevant and the solution didn't help me)
We might be able to work around this by setting -DANDROID_STL=c++_static
, but this has other issues, mainly, it violates Android's guidelines for using multiple shared libraries, though it might be possible for for middleware vendors
So the question is,
- Is it possible to build Mediapipe (or any other Bazel based) using
c++_shared
Android STL
- If not, are there any other options to solve the runtime conflicts
- Is it even a runtime conflict or something else?
发布评论
评论(1)
我设法按照我们所有共享对象(SDK,MediaPipe,OpenCV等)对使用
c ++ _ static
的建议工作。I managed to get it working as suggested by using
c++_static
on all of our shared objects (SDK, Mediapipe, OpenCV and others)