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.
)