Cmake 配置问题

rt7856出现以下问题:
之前一直是报undefined reference to __print_Log 打印log的类找不到。因为Cmake配置错误,不知道之前的错误是什么样子了。
最终的配置在后面。

Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
Error while executing 'C:\Users\Administrator\AppData\Local\Android\sdk\cmake\3.6.3155560\bin\cmake.exe' with arguments {--build C:\Users\Administrator\Desktop\newFile\RSA\app\.externalNativeBuild\cmake\debug\x86 --target native-lib}
[1/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/assertutils.cpp.o
[3/3] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libnative-lib.so
FAILED: cmd.exe /C "cd . && C:\Users\Administrator\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  -target i686-none-linux-android -gcc-toolchain C:/Users/Administrator/AppData/Local/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/Administrator/AppData/Local/Android/sdk/ndk-bundle/platforms/android-14/arch-x86 -fPIC -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti  -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info  -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/assertutils.cpp.o  -llog -lm "C:/Users/Administrator/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/libgnustl_static.a" && cd ."
C:\Users\Administrator\Desktop\newFile\RSA\app\src\main\cpp/native-lib.cpp:31: error: undefined reference to 'AAssetManager_fromJava'
  C:\Users\Administrator\Desktop\newFile\RSA\app\src\main\cpp/native-lib.cpp:39: error: undefined reference to 'AAssetManager_open'
  C:\Users\Administrator\Desktop\newFile\RSA\app\src\main\cpp/native-lib.cpp:40: error: undefined reference to 'AAsset_getLength'
  C:\Users\Administrator\Desktop\newFile\RSA\app\src\main\cpp/native-lib.cpp:43: error: undefined reference to 'AAsset_read'
  C:\Users\Administrator\Desktop\newFile\RSA\app\src\main\cpp/native-lib.cpp:49: error: undefined reference to 'AAsset_close'
  clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
             native-lib
             src/main/cpp/native-lib.cpp

              src/main/cpp/assertutils.cpp
              src/main/cpp/Logger.hpp)

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log
              android
              )
 target_link_libraries( # Specifies the target library.
                       native-lib
                       android
                       ${log-lib}

                       # Links the target library to the log library
                       # included in the NDK.
                       )

教程地址

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值