如何链接验证层?

时间:2018-05-17 16:02:48

标签: android vulkan

我在创建renderpass时遇到了一些麻烦,所以我想启用一些验证层。但是当我将它们添加到CMakeLists.txt文件,然后尝试运行该项目时,我收到此错误消息。有没有办法加载libVkLayer _..._ validation.so文件?

FAILED: cmd.exe /C "cd . && C:\Users\Lacko\AppData\Local\Android\sdk11\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=aarch64-none-linux-android --gcc-toolchain=C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sysroot -fPIC -isystem C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=26 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11 -frtti -fexceptions -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/platforms/android-26/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LC:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libvulkan_module.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\arm64-v8a\libvulkan_module.so CMakeFiles/vulkan_module.dir/src/main/cpp/vulkan_func.cpp.o CMakeFiles/vulkan_module.dir/src/main/cpp/vulkan_base.cpp.o CMakeFiles/vulkan_module.dir/src/main/cpp/vulkan_render_surface.cpp.o CMakeFiles/vulkan_module.dir/src/main/cpp/vulkan_draw_command.cpp.o CMakeFiles/vulkan_module.dir/src/main/cpp/vulkan_render_command.cpp.o CMakeFiles/vulkan_module.dir/src/main/cpp/vulkan_commands.cpp.o CMakeFiles/vulkan_module.dir/src/main/cpp/vulkan_module.cpp.o -LC:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/mips -lVkLayer_core_validation -lVkLayer_threading -lVkLayer_parameter_validation -lVkLayer_object_tracker -lVkLayer_unique_objects -llog -latomic -lm "C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_static.a" "C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++abi.a" && cd ."
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: skipping incompatible C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/mips/libVkLayer_core_validation.so when searching for -lVkLayer_core_validation
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: cannot find -lVkLayer_core_validation
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: skipping incompatible C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/mips/libVkLayer_threading.so when searching for -lVkLayer_threading
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: cannot find -lVkLayer_threading
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: skipping incompatible C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/mips/libVkLayer_parameter_validation.so when searching for -lVkLayer_parameter_validation
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: cannot find -lVkLayer_parameter_validation
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: skipping incompatible C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/mips/libVkLayer_object_tracker.so when searching for -lVkLayer_object_tracker
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: cannot find -lVkLayer_object_tracker
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: skipping incompatible C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/mips/libVkLayer_unique_objects.so when searching for -lVkLayer_unique_objects
C:/Users/Lacko/AppData/Local/Android/sdk11/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: cannot find -lVkLayer_unique_objects
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

这是CMakeList.txt文件:

cmake_minimum_required(VERSION 3.4.1)

link_directories(${ANDROID_NDK}/sources/third_party/vulkan/src/build-android/jniLibs/mips)

add_library( native-lib
             SHARED
             src/main/cpp/native-lib.cpp
             src/main/cpp/graphics_module.cpp)

add_library( vulkan_module
             SHARED
             src/main/cpp/vulkan_func.cpp
             src/main/cpp/vulkan_base.cpp
             src/main/cpp/vulkan_render_surface.cpp
             src/main/cpp/vulkan_draw_command.cpp
             src/main/cpp/vulkan_render_command.cpp
             src/main/cpp/vulkan_commands.cpp
             src/main/cpp/vulkan_module.cpp)


find_library( log-lib
              log )

target_link_libraries(vulkan_module
                      VkLayer_core_validation
                      VkLayer_threading
                      VkLayer_parameter_validation
                      VkLayer_object_tracker
                      VkLayer_unique_objects
                      ${log-lib} )

target_link_libraries( native-lib
                       vulkan_module
                       android
                       ${log-lib} )

1 个答案:

答案 0 :(得分:1)

不要链接验证图层。您需要做的就是在apk中包含验证层二进制文件以及您的apk或系统范围路径中的某个位置,然后它只是启用图层以使验证工作。然后由加载程序完成定位和加载库。

如果您正在使用NDK r12(或更高版本),则会包含预先构建的验证图层,并且可以通过gradle轻松添加。请参阅此here的官方文档。

另一种选择是从official repository手动为目标体系结构构建Android验证图层,并将其手动添加到Android版本中。虽然这需要更多的努力,但您始终可以获得最新的验证功能。