When compiling the HAP, add build dependencies libneural_network_core.so and libhiai_foundation.so in the NDK for the .so files at the NAPI layer.
Include the header files of NNCore and CANN Kit as required.
#include "neural_network_runtime/neural_network_core.h" #include "CANNKit/hiai_options.h"
The sample code for compiling CMakeLists.txt is as follows:
# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(CANNDemo)
set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${NATIVERENDER_ROOT_PATH}
${NATIVERENDER_ROOT_PATH}/include)
include_directories(${HMOS_SDK_NATIVE}/sysroot/usr/lib)
FIND_LIBRARY(cann-lib hiai_foundation)
add_library(entry SHARED Classification.cpp HIAIModelManager.cpp)
target_link_libraries(entry PUBLIC libace_napi.z.so
libhilog_ndk.z.so
librawfile.z.so
${cann-lib}
libneural_network_core.so
)