android .a ndk,Android NDK Cmake链接.a(静态)Libs

我正在使用带有cmake和Android NDK的Android Studio 2.2.2.我有一个链接.a库(静态库)的问题.

这是我的cmake:

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

# library. You should either keep the default value or only pass a

# value of 3.4.0 or lower.

cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_VERBOSE_MAKEFILE on)

# Creates and names a library, sets it as either STATIC

# or SHARED, and provides the relative paths to its source code.

# You can define multiple libraries, and CMake builds it for you.

# Gradle automatically packages shared libraries with your APK.

add_library(lib_webp SHARED IMPORTED )

set_target_properties(lib_webp PROPERTIES IMPORTED_LOCATION

src/main/jni/${ANDROID_ABI}/libwebp.so)

add_library( # Sets the name of the library.

game-lib

# Sets the library as a shared library.

SHARED

# Provides a relative path to your source file(s).

# Associated headers in the same location as their source

# file are automatically included.

src/main/cpp/main.cpp

src/main/cpp/android_native_app_glue.c

)

target_include_directories(game-lib PRIVATE

../../../../libs/headers/android

)

include_directories($ENV{NDK_MODULE_PATH}/sources/android/native_app_glue/)

# Specifies libraries CMake should link to your target library. You

# can link multiple libraries, such as libraries you define in the

# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.

game-lib

# Links the target library to the log library

# included in the NDK.

# ${log-lib}

# Specifies the name of the NDK library that

# you want CMake to locate.

log

android

OpenSLES

z

GLESv2

EGL

dl

)

add_definitions(-g -DANDROID -Wno-write-strings -fsigned-char -Wno-conversion-null)

TARGET_LINK_LIBRARIES(game-lib libtheoraplayer.a)

我的链接器报告错误

arm-linux-androideabi/bin\ld: error: cannot find -ltheoraplayer

error: undefined reference to ‘TheoraVideoManager::TheoraVideoManager(int)’

这是libtheoraplayer.a的一部分.有没有人有类似的问题?不知道怎么解决这个问题?

我在那个位置有静态lib libtheoraplayer.a.我甚至还有共享库,libtheoraplayer.so但我也无法链接它.

任何意见,将不胜感激.

干杯.

解决方法:

发布答案.正如Tsyvarev所说,库的非绝对文件名存在问题.当我使用absoulte路径时,它就像一个魅力.

谢谢.

干杯.

标签:android,linker,android-ndk,cmake,linker-errors

来源: https://codeday.me/bug/20190519/1134259.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值