How do I build the arcore camera_utility shared library in NDK-BUILD?

家住魔仙堡 提交于 2019-12-11 06:11:11

问题


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

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.

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

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)

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?


回答1:


To compile arcore_camera_utility for the arm 64bit target-

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

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.) get the three .cc files and the three .h files and place them in the jni directory

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.) 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.) 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.) Open a terminal or powershell, go to the root directory (arcorelibrary) of your project

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.) Run:

ndk-build.cmd


来源:https://stackoverflow.com/questions/58195077/how-do-i-build-the-arcore-camera-utility-shared-library-in-ndk-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!