CMake未能找到图书馆,我不知道为什么。这是我的CMakeLists.txt中应该找到库的部分:
set(SODIUM_DIR ${PROJECT_SOURCE_DIR}/../../../deps/install/libsodium/android-${ANDROID_ABI}/lib)
message(STATUS SODIUM_DIR=${SODIUM_DIR})
find_library(sodium-lib
libsodium.a
PATHS ${SODIUM_DIR}
NO_DEFAULT_PATH)
CMake的部分输出是:
-- SODIUM_DIR=/Users/csimmons/Documents/repos/onedoclily/client/Android/app/../../../deps/install/libsodium/android-armeabi-v7a/lib
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
-- Configuring incomplete, errors occurred!
Please set them or make sure they are set and tested correctly in the CMake files:
See also "/Users/csimmons/Documents/repos/onedoclily/client/Android/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
sodium-lib
linked by target "native-lib" in directory /Users/csimmons/Documents/repos/onedoclily/client/Android/app
Build command failed.
在SODIUM_DIR上运行“ls”表示该库在那里:
$ ls /Users/csimmons/Documents/repos/onedoclily/client/Android/app/../../../deps/install/libsodium/android-armeabi-v7a/lib
libsodium.a libsodium.la libsodium.so pkgconfig
答案 0 :(得分:0)
在可能的名称列表之前缺少标记NAMES
。
修正:
find_library(sodium-lib
NAMES libsodium.a
PATHS ${SODIUM_DIR}
NO_DEFAULT_PATH)
答案 1 :(得分:0)
我相信我已经能够通过使用add_library和set_property而不是find_library来解决问题。
set(SODIUM_PATH ${PROJECT_SOURCE_DIR}/../../../deps/install/libsodium/android-${ANDROID_ABI}/lib/libsodium.a)
add_library(sodium-lib STATIC IMPORTED)
set_property(TARGET sodium-lib PROPERTY IMPORTED_LOCATION ${SODIUM_PATH})
target_link_libraries( # My code's library.
native-lib
sodium-lib
)