Hello i’m trying to modify android’s settings to use the optee os on a hikey 960. I’m currently having trouble with linking libteec. this is unique because i’m not developing a standalone app or buildling it on my computer. the file sturcture of the project is this:
settings
+--jni
+--android.mk
+--hellojni.c
+--tee_client_api.h
+
+--android.mk
and in the android make at settings i’m including my libhello-jni.so file in this manner.
ZPATH := $(LOCAL_PATH)
include $(ZPATH)/jni/Android.mk
LOCAL_JNI_SHARED_LIBRARIES := libhello-jni
I was able to get that working just calling a native library. Here is my make file within the jni folder trying to include .so file.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libteec
LOCAL_SRC_FILES := /storage/optee_android_manifest/out/target/product/hikey960/vendor/lib/libteec.so
include $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)
LOCAL_MODULE := libhello-jni
LOCAL_SRC_FILES := hello-jni.cLOCAL_C_INCLUDES +=
$(JNI_H_INCLUDE)LOCAL_CFLAGS += -O0 -g3
include $(BUILD_SHARED_LIBRARY)
this is the error i get
[ 16% 4/25] target SharedLib: libhello-jni (out/target/product/hikey960/obj/SHARED_LIBRARIES/libhello-jni_intermediates/LINKED/libhello-jni.so)
FAILED: out/target/product/hikey960/obj/SHARED_LIBRARIES/libhello-jni_intermediates/LINKED/libhello-jni.so
/bin/bash -c "prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ -nostdlib -Wl,-soname,libhello-jni.so -Wl,--gc-sections -shared out/target/product/hikey960/obj/lib/crtbegin_so.o out/target/product/hikey960/obj/SHARED_LIBRARIES/libhello-jni_intermediates/hello-jni.o -Wl,--whole-archive -Wl,--no-whole-archive out/target/product/hikey960/obj/STATIC_LIBRARIES/libclang_rt.ubsan_minimal-aarch64-android_intermediates/libclang_rt.ubsan_minimal-aarch64-android.a out/target/product/hikey960/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a out/target/product/hikey960/obj/STATIC_LIBRARIES/libatomic_intermediates/libatomic.a out/target/product/hikey960/obj/STATIC_LIBRARIES/libgcc_intermediates/libgcc.a -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5 -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined-version -Wl,-m,aarch64_elf64_le_vec -Wl,--hash-style=gnu -fuse-ld=gold -Wl,--icf=safe -Wl,--fix-cortex-a53-843419 -target aarch64-linux-android -Bprebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin -Wl,--exclude-libs,libclang_rt.ubsan_minimal-aarch64-android.a -Wl,--no-undefined out/target/product/hikey960/obj/lib/libc++.so out/target/product/hikey960/obj/lib/libc.so out/target/product/hikey960/obj/lib/libm.so out/target/product/hikey960/obj/lib/libdl.so -o out/target/product/hikey960/obj/SHARED_LIBRARIES/libhello-jni_intermediates/LINKED/libhello-jni.so out/target/product/hikey960/obj/lib/crtend_so.o"
packages/apps/Settings/jni/hello-jni.c:42: error: undefined reference to 'TEEC_InitializeContext'
packages/apps/Settings/jni/hello-jni.c:50: error: undefined reference to 'TEEC_OpenSession'
packages/apps/Settings/jni/hello-jni.c:80: error: undefined reference to 'TEEC_InvokeCommand'
packages/apps/Settings/jni/hello-jni.c:95: error: undefined reference to 'TEEC_CloseSession'
packages/apps/Settings/jni/hello-jni.c:97: error: undefined reference to 'TEEC_FinalizeContext'
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
[ 20% 5/25] target SharedLib: libhello-jni_32 (out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libhello-jni_intermediates/LINKED/libhello-jni.so)
FAILED: out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libhello-jni_intermediates/LINKED/libhello-jni.so
/bin/bash -c "prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ -nostdlib -Wl,-soname,libhello-jni.so -Wl,--gc-sections -shared out/target/product/hikey960/obj_arm/lib/crtbegin_so.o out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libhello-jni_intermediates/hello-jni.o -Wl,--whole-archive -Wl,--no-whole-archive out/target/product/hikey960/obj_arm/STATIC_LIBRARIES/libunwind_llvm_intermediates/libunwind_llvm.a out/target/product/hikey960/obj_arm/STATIC_LIBRARIES/libclang_rt.ubsan_minimal-arm-android_intermediates/libclang_rt.ubsan_minimal-arm-android.a out/target/product/hikey960/obj_arm/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a out/target/product/hikey960/obj_arm/STATIC_LIBRARIES/libatomic_intermediates/libatomic.a out/target/product/hikey960/obj_arm/STATIC_LIBRARIES/libgcc_intermediates/libgcc.a -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5 -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined-version -Wl,--icf=safe -Wl,--hash-style=gnu -Wl,-m,armelf -target arm-linux-androideabi -Bprebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/arm-linux-androideabi/bin -Wl,--exclude-libs,libunwind_llvm.a -Wl,--exclude-libs,libclang_rt.ubsan_minimal-arm-android.a -Wl,--no-undefined out/target/product/hikey960/obj_arm/lib/libc++.so out/target/product/hikey960/obj_arm/lib/libc.so out/target/product/hikey960/obj_arm/lib/libm.so out/target/product/hikey960/obj_arm/lib/libdl.so -o out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libhello-jni_intermediates/LINKED/libhello-jni.so out/target/product/hikey960/obj_arm/lib/crtend_so.o"
packages/apps/Settings/jni/hello-jni.c:42: error: undefined reference to 'TEEC_InitializeContext'
packages/apps/Settings/jni/hello-jni.c:50: error: undefined reference to 'TEEC_OpenSession'
packages/apps/Settings/jni/hello-jni.c:80: error: undefined reference to 'TEEC_InvokeCommand'
packages/apps/Settings/jni/hello-jni.c:95: error: undefined reference to 'TEEC_CloseSession'
packages/apps/Settings/jni/hello-jni.c:97: error: undefined reference to 'TEEC_FinalizeContext'
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
[ 24% 6/25] build out/target/common/obj/APPS/Settings_intermediates/classes-combined.jar