CMAKE删除lib并使用一个预构建版本

问题描述

在我的CMAKE项目中,我目前使用源代码来编译库,并最终使用它与JNI库进行链接。我现在想删除我的库 FoxsdkCore 的构建步骤,而只是构建JNI库并将其链接到预构建的 FoxsdkCore

我的脚本当前看起来像:

# For more @R_503_4045@ion about using CMake with Android Studio,read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

set(PATH_TO_FOxsdk "~/Downloads/fosdkcore")
message(${PATH_TO_FOxsdk})

add_deFinitions(-DLINUX)
add_deFinitions(-D_FILE_OFFSET_BITS=64)
set( CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++" )
set(CMAKE_BUILD_TYPE Debug)

include_directories(${PATH_TO_FOxsdk}/Include)
include_directories(${PATH_TO_FOxsdk}/Development/winhdrs)
include_directories(${PATH_TO_FOxsdk}/Development/SDK)
find_package(JNI)

if (JNI_FOUND)
    message (STATUS "JNI_INCLUDE_Dirs=${JNI_INCLUDE_Dirs}")
    message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
endif()

include_directories(${JNI_INCLUDE_Dirs})

set(fox_files
        ${PATH_TO_FOxsdk}/Development/SDK/CallBacks.h
       ...
        )


add_library(FoxsdkCore
        SHARED
        ${fox_files})

add_library( # Sets the name of the library.
        JNIViie
        # Sets the library as a shared library.
        SHARED
        # Provides a relative path to your source file(s).
        JNIViie.cpp
        )

target_link_libraries(FoxsdkCore
        ${CMAKE_THREAD_LIBS_INIT}
        )

target_link_libraries( # Specifies the target library.
        JNIViie
        FoxsdkCore)

据我了解,我必须设置IMPORTED标志,所以我使用



add_library(FoxsdkCore
        SHARED
        IMPORTED)

add_library( # Sets the name of the library.
        JNIViie
        # Sets the library as a shared library.
        SHARED
        # Provides a relative path to your source file(s).
        JNIViie.cpp
        )

target_link_libraries( # Specifies the target library.
        JNIViie
        FoxsdkCore)

但这将失败。任何提示如何链接现有库?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)