编译so库,运行时加载so库报错,运行时加载路径是编译时的路径

 

 

编译so库,运行时加载so库报错,运行时加载路径是编译时的路径,而不是运行时app的安装路径/data/storage/el1/bundle/libs/arm64/,查看安装路径是有对应的so库的

08-31 10:37:09.826 8970-8970/? W C03900/NAPI: [native_module_manager.cpp(LoadModuleLibrary)] dlopen failed: Error loading shared library G:/code/szzt_pantu_printer/entry/src/main/cpp/libs/hello.so: No such file or directory (needed by /data/storage/el1/bundle/libs/arm64/libentry.so)
08-31 10:39:53.000 9180-9180/? W C03900/NAPI: [native_module_manager.cpp(LoadModuleLibrary)] dlopen failed: Error loading shared library G:/code/szzt_pantu_printer/entry/src/main/cpp/libs/hello.so: No such file or directory (needed by /data/storage/el1/bundle/libs/arm64/libentry.so)
 

 

根据网上的办法通过链接参数设置运行时搜索路径,没有生效,希望有了解的大神指点一下

set_target_properties(hello
          PROPERTIES IMPORTED_LOCATION
          ${NATIVERENDER_ROOT_PATH}/libs/hello.so LINK_FLAGS "-Wl,-rpath,'./'")

 

target_link_libraries(entry PUBLIC hello -Wl,-rpath,./)
Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐