CMakeLists文件不生成.so文件

时间:2017-11-16 14:07:39

标签: android cmake android-ndk android-gradle oggvorbis

我正在尝试使用CMake在Android项目上实现lib ogg和vorbis。代码基于此repository。我试图根据谷歌的推荐和OpenCV的一个例子来构建源代码。编译工作但.so文件未附加到APK。有什么想法解决它吗?

cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

set(root_DIR ${CMAKE_SOURCE_DIR})

include_directories(
    ${root_DIR}/include
    ${root_DIR}/include/ogg
    ${root_DIR}/include/stream
    ${root_DIR}/include/vorbis
    ${root_DIR}/libvorbis
    ${root_DIR}/libogg
)

file(GLOB_RECURSE libogg
    "${root_DIR}/libogg/*.c"
    "${root_DIR}/libogg/*.cpp"
)

file(GLOB_RECURSE libvorbis
    "${root_DIR}/libvorbis/*.c"
    "${root_DIR}/libvorbis/*.cpp"
)

file(GLOB_RECURSE org_xiph_vorbis_decode
    "${root_DIR}/libvorbis/*.c"
    "${root_DIR}/libvorbis/*.cpp"
)

file(GLOB_RECURSE org_xiph_vorbis_encoder
    "${root_DIR}/libvorbis/*.c"
    "${root_DIR}/libvorbis/*.cpp"
)

# add our library
add_library(libogg STATIC ${libogg})
add_library(libvorbis STATIC ${libvorbis})
add_library(org_xiph_vorbis_decoder STATIC ${org_xiph_vorbis_decode})
add_library(org_xiph_vorbis_encoder STATIC ${org_xiph_vorbis_encoder})

# configure import libs
set(lib_DIR ${root_DIR}/src/main/jniLibs)

# Add the shared library
add_library(imported-lib SHARED IMPORTED)

# Directory for compiled binary
set(target_DIR ${lib_DIR}${ANDROID_ABI}/imported-lib.so)

# Link libraries on build directory
set_target_properties(imported-lib PROPERTIES IMPORTED_LOCATION ${target_DIR})

find_library(log-lib log)
find_library(z-lib z)

target_link_libraries(
    # Specifies the target library.
    libvorbis
    libogg

    imported-lib

    org_xiph_vorbis_encoder_VorbisEncoder
    org_xiph_vorbis_decoder_VorbisDecoder

    # Links the target library to the log library
        # included in the NDK.
    ${z-lib}
    ${log-lib}
)

源代码在这里:https://github.com/ppamorim/jni_vorbis

谢谢,我真的很感激任何帮助。

0 个答案:

没有答案