Getting Started with Vulkan - Compiling Shaderc

When compiling Vulkan-Samples , I encountered the following shaderc compilation error.

ninja: error: '/Users/xiaxl/Library/Android/sdk/ndk/21.1.6352462/sources/third_party/shaderc/libs/c++_static/armeabi-v7a/libshaderc.a', needed by '../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/lib-vulkan-lib.so', missing and no known rule to make it

ninja: error: libshaderc.a

1. Cause of error

After checking the official Shaderc related introduction, it was confirmed that the cause of the error was that Shaderc was not compiled.
When Android Studio compiles Vulkan-Samples related projects, it cannot find libshaderc.adependent packages and reports an error.

2. Problem solving

We need to refer to the official Shaderc related description and perform Shaderc compilation:

  1. Enter <ndk-root>/sources/third_party/shaderc/directory;
  2. Execute the following compilation command according to the official description:
# linux或Mac终端操作系统:
../../../ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk \
APP_STL:=c++_static APP_ABI=all libshaderc_combined -j16

# Windows操作系统:
..\..\..\ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk ^
APP_STL:=c++_static APP_ABI=all libshaderc_combined -j16
  1. Check after compilation is completed:
    After compilation is completed, <ndk_root>/sources/third_party/shaderc/the following files will be generated in the directory:
# 编译后生成的文件
include/
  shaderc/
    shaderc.h
    shaderc.hpp
libs/
  <stl_version>/
    {all of the abis}
       libshaderc.a

File generated after compiling shaderc

3. Reference

AndroidDev: Getting started with Vulkan
https://developer.android.google.cn/ndk/guides/graphics/getting-started?hl=zh

AndroidDev:编译Shaderc
https://developer.android.google.cn/ndk/guides/graphics/shader-compilers?hl=zh-cn

Guess you like

Origin blog.csdn.net/aiwusheng/article/details/132886412