Android NDK 引入外部动态库.so报错 missing and no known rule

正确的配置项-cmake

add_library( qtcore
              SHARED
              IMPORTED )
set_target_properties( # Specifies the target library.
              qtcore
              # Specifies the parameter you want to define.
              PROPERTIES IMPORTED_LOCATION
              # 关键点在这里,这个路径必须为绝对路径,报错原因是因为使用了相对路径
              ${PROJECT_SOURCE_DIR}/../libs/${ANDROID_ABI}/libQt6Core.so )

target_link_libraries( # Specifies the target library.
              shared
              qtcore
              # Links the target library to the log library
              # included in the NDK.
              ${log-lib})
  • 关键点在这里,这个路径必须为绝对路径,报错原因是因为使用了相对路径