From 70cbf6ccafd161de609faee524afb34b5efb1f57 Mon Sep 17 00:00:00 2001 From: HEYAHONG <2229388563@qq.com> Date: Thu, 9 Jan 2025 11:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8DSO=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E5=AE=89=E8=A3=85=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/src/main/cpp/CMakeLists.txt | 3 ++- .../app/src/main/cpp/native-lib.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test/Android/HelloWorld/app/src/main/cpp/CMakeLists.txt b/test/Android/HelloWorld/app/src/main/cpp/CMakeLists.txt index 04bd4e2..1286510 100644 --- a/test/Android/HelloWorld/app/src/main/cpp/CMakeLists.txt +++ b/test/Android/HelloWorld/app/src/main/cpp/CMakeLists.txt @@ -53,4 +53,5 @@ hrc_enable(${PROJECT_NAME}) target_link_libraries(${CMAKE_PROJECT_NAME} # List libraries link to the target library android - log) \ No newline at end of file + log + dl) \ No newline at end of file diff --git a/test/Android/HelloWorld/app/src/main/cpp/native-lib.cpp b/test/Android/HelloWorld/app/src/main/cpp/native-lib.cpp index 0da6754..94538c3 100644 --- a/test/Android/HelloWorld/app/src/main/cpp/native-lib.cpp +++ b/test/Android/HelloWorld/app/src/main/cpp/native-lib.cpp @@ -4,10 +4,28 @@ #include "hbox.h" #include "HCPPBox.h" #include +#include #define LOGI(...) \ ((void)__android_log_print(ANDROID_LOG_INFO, "helloworld-libs::", __VA_ARGS__)) + +static std::string GetCurrentLibPATH() +{ + std::string ret; + void * handle = dlopen(NULL,RTLD_LAZY); + if(handle!=NULL) + { + Dl_info info= {0}; + if(dladdr((const void *)GetCurrentLibPATH,&info)) + { + ret=info.dli_fname; + } + dlclose(handle); + } + return ret; +} + extern "C" JNIEXPORT jstring JNICALL Java_cn_hyhsystem_hcppbox_helloworld_MainActivity_stringFromJNI( JNIEnv* env, @@ -34,6 +52,7 @@ extern "C" JNIEXPORT void JNICALL Java_cn_hyhsystem_hcppbox_helloworld_MainActivity_Init(JNIEnv *env, jobject thiz) { LOGI("Init"); + LOGI("Lib_PATH:%s",GetCurrentLibPATH().c_str()); } /*