【发布时间】:2018-09-19 01:40:16
【问题描述】:
我正在尝试在其中一个项目的 android 模块中导入外部 C/C++ 库。该库称为android-fluidsynth。我正在按照this link 的说明进行集成。以下是我的CMakeLists.txt 的样子:
EDIT 2:下面的工作
# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.
cmake_minimum_required(VERSION 3.4.1)
######################################################################################
######### Adding fluidsynth library from the external code
######################################################################################
# Sets lib_src_DIR to the path of the target CMake project.
set(fluidsynth-lib-name libfluidsynthsrc)
set( lib_DIR /Users/swapnilgupta/work/musicmuni/fluidsynth-android/android/ )
# Sets lib_build_DIR to the path of the desired output directory.
set( lib_build_DIR ${lib_DIR}/outputs )
file(MAKE_DIRECTORY ${lib_build_DIR})
# Adds the CMakeLists.txt file located in the specified directory
# as a build dependency.
add_subdirectory( # Specifies the directory of the CMakeLists.txt file.
${lib_DIR}
# Specifies the directory for the build outputs.
${lib_build_DIR} )
# Adds the output of the additional CMake build as a prebuilt static
# library and names it.
add_library( ${fluidsynth-lib-name}
SHARED
IMPORTED )
set_target_properties( ${fluidsynth-lib-name} PROPERTIES IMPORTED_LOCATION
${lib_build_DIR}/${ANDROID_ABI}/lib${fluidsynth-lib-name}.so )
在尝试构建时,我收到以下错误:
install TARGETS given no RUNTIME DESTINATION for executable target "fluidsynth"
我浏览了一些 SO 帖子并在我的 CMakeLists.txt 中添加了以下几行,但我仍然收到此错误。
if(WIN32)
install(TARGETS fluidsynth
RUNTIME DESTINATION ./)
else()
install(TARGETS fluidsynth
LIBRARY DESTINATION ./)
endif()
有人可以帮忙吗?
【问题讨论】:
-
错误信息似乎很清楚:
fluidsynth是一个可执行目标,因此它需要 RUNTIME DESTINATION。但是您的代码为非 Windows 平台设置了 LIBRARY DESTINATION。顺便说一句,您显示的代码不包含fluidsynth目标的创建,它只创建libfluidsynth一个。
标签: android c++ cmake android-ndk