如何在 NDK-BUILD 中构建 arcore camera_utility 共享库? [英] How do I build the arcore camera_utility shared library in NDK-BUILD?

查看:24
本文介绍了如何在 NDK-BUILD 中构建 arcore camera_utility 共享库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 NDK_BUILD 中构建arcore 相机实用程序"库,这里:https://github.com/google-ar/arcore-unity-sdk/tree/master/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src

I'm trying to build the 'arcore camera utility' library in NDK_BUILD, here: https://github.com/google-ar/arcore-unity-sdk/tree/master/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src

使用本指南:https://yeephycho.github.io/2016/10/20/How-to-Use-NDK-to-Build-A-Shared-Android_Native-Library/ 我至少能够让它在 libarcore_camera_utility.so 文件中编译.不仅如此,我的应用程序在手机上实际识别了它,我收到错误消息:EntryPointNotFoundException:无法在‘arcore_camera_utility’中找到名为‘TextureReader_create’的入口点,而不是出现 DLL 丢失错误."这意味着它至少现在找到了文件.

Using this guide: https://yeephycho.github.io/2016/10/20/How-to-Use-NDK-to-Build-A-Shared-Android_Native-Library/ I was at least able to get it to compile in a libarcore_camera_utility.so file. Not only that but it was actually recognized by my app on the phone and instead of getting a DLL missing error I got the error: "EntryPointNotFoundException: Unable to find an entry point named 'TextureReader_create' in 'arcore_camera_utility'." which means it at least found the file, now.

.so 的文件大小只有 6k,所以看起来我没有正确编译它,因为包附带的已经可以工作的 32 位版本是 100k,基于这个问题,我似乎遗漏了一些东西?: 未找到入口点,Android .so 文件

The filesize of the .so is only 6k so it seems like I'm not compiling it correctly as the already working 32bit version that comes with the package is 100k, based on this question it seems like I'm leaving something out?: Entry point not found, Android .so file

我的 Android.mk 文件是:

My Android.mk file is:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := arcore_camera_utility_shared
LOCAL_C_INCLUDES += \
LOCAL_SRC_FILES := camera_utility.cc gl_utility.cc texture_reader.cc
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := arcore_camera_utility
LOCAL_WHOLE_STATIC_LIBRARIES := arcore_camera_utility_shared
include $(BUILD_SHARED_LIBRARY)

我的 Application.mk 文件包含:

And my Application.mk file contains:

APP_ABI := arm64-v8a
APP_PLATFORM := android-24
APP_STL := c++_static
APP_BUILD_SCRIPT := ./jni/Android.mk

我在构建它时是否忽略了代码?

Am I building it in such a way as to leave the code out?

推荐答案

为arm 64bit target编译arcore_camera_utility-

To compile arcore_camera_utility for the arm 64bit target-

1.) 创建一个名为arcorelibrary"的新目录,然后创建一个名为jni"的子目录

1.) Create a new directory called 'arcorelibrary', then a subdirectory called 'jni'

2.) 下载此 zip:https://github.com/google-ar/arcore-unity-sdk/blob/master/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip

2.) Download this zip: https://github.com/google-ar/arcore-unity-sdk/blob/master/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip

3.) 获取三个 .cc 文件和三个 .h 文件并将它们放在 jni 目录中

3.) get the three .cc files and the three .h files and place them in the jni directory

4.) 创建一个名为Android.mk"的文件并将其放在jni目录下,内容如下:

4.) Create a file called 'Android.mk' and place it in the jni directory, with the following contents:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= arcore_camera_utility_static
LOCAL_SRC_FILES:= camera_utility.cc gl_utility.cc texture_reader.cc
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS    := -llog -landroid -lEGL -lGLESv2 -lGLESv3
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := arcore_camera_utility
LOCAL_WHOLE_STATIC_LIBRARIES := arcore_camera_utility_static
include $(BUILD_SHARED_LIBRARY)

5.) 创建一个名为Application.mk"的文件并将其放在 jni 目录中,内容如下:

5.) Create a file called 'Application.mk' and place it in the jni directory, with the following contents:

APP_ABI := arm64-v8a
APP_PLATFORM := android-24
APP_STL := c++_static
APP_BUILD_SCRIPT := ./jni/Android.mk

6.) 下载 Android NDK 并在某处解压缩(您需要的版本取决于您使用的 Unity 版本)https://developer.android.com/ndk/downloads/older_releases.html

6.) Download Android NDK and unzip somewhere (The version you need depends on which Unity version you're using) https://developer.android.com/ndk/downloads/older_releases.html

7.) 打开终端或 powershell,转到项目的根目录(arcorelibrary)

7.) Open a terminal or powershell, go to the root directory (arcorelibrary) of your project

8.) 创建一个你解压 Android NDK 的路径(Powershell 示例):

8.) Create a path to where ever you unzipped Android NDK (Powershell example):

$env:Path += ";C:\[where-ever-you-unzipped]\android-ndk-r13b-windows-x86_64\android-ndk-r13b"

9.) 运行:

ndk-build.cmd

这篇关于如何在 NDK-BUILD 中构建 arcore camera_utility 共享库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆