本文介绍了cmake:missing,导入预建库时没有已知规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用此CmakeLists.txt片段导入预构建的库:

I want to import a prebuilt library using this CmakeLists.txt snippet:

add_library(openssl-crypto
            SHARED
            IMPORTED )
set_target_properties(openssl-crypto
                      PROPERTIES
                      IMPORTED_LOCATION
                      ${external_DIR}/libs/${ANDROID_ABI}/libcrypto.so )
include_directories(${external_DIR}/include/openssl)

我将此链接链接到我的库为:

I linked this to my library as:

target_link_libraries(aes-crypto openssl-crypto)

尝试构建会返回以下错误:

Attempting to build returns this error:

'/libs/arm64-v8a/libcrypto.so', needed by ...,  missing and no known rule to make it


推荐答案

set_target_properties 函数不喜欢相对路径。

I found that the set_target_properties function doesn't like relative paths.

来自

From the CMake Documentation on IMPORTED_LOCATION






要解决此问题,我改为使用库的完整路径。


To resolve this issue, I used the full path to the library instead.

示例:

set_target_properties ( curl-lib 
                        PROPERTIES IMPORTED_LOCATION 
                        libs/${ANDROID_ABI}/libcurl.a )

. . . becomes . . . 

set_target_properties ( curl-lib 
                        PROPERTIES IMPORTED_LOCATION 
                        ${PROJECT_SOURCE_DIR}/src/main/cpp/libs/${ANDROID_ABI}/libcurl.a )

这篇关于cmake:missing,导入预建库时没有已知规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 22:09