Issue
I want to run Vulkan on my android phone, and currently, I'm stuck at the point trying to make CMake find the libshaderc
.
What I did is first build the shaderc:
cd <my-ndk-root>/sources/third_party/shaderc
../../../ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_STL:=c++_static APP_ABI=all NDK_TOOLCHAIN_VERSION:=clang libshaderc_combined -j16
And inside my CMakeLists.txt
, I have:
get_filename_component(SHADERC_SRC
${ANDROID_NDK}/sources/third_party/shaderc
ABSOLUTE)
add_library(shaderc_lib STATIC IMPORTED)
set_target_properties(shaderc_lib PROPERTIES IMPORTED_LOCATION
${SHADERC_SRC}/libs/${ANDROID_STL}/${ANDROID_ABI}/libshaderc.a)
But the CMake can't find the shaderc_lib, and failed with error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
shaderc_lib
Please note that I already checked that I have libshaderc.a
under the [my-ndk-root]/sources/third_party/shaderc/libs
:
.
└── c++_static
├── arm64-v8a
│ └── libshaderc.a
├── armeabi-v7a
│ └── libshaderc.a
├── x86
│ └── libshaderc.a
└── x86_64
└── libshaderc.a
5 directories, 4 files
I'm not very familiar with CMake and NDK, so if I made some stupid mistakes, please correct me. Thanks in advance!
Solution
Make sure your CMake path points to the correct place. Also, your libshaderc.a
is static library and you need to link it to your shared lib, e.g. libshaderc-shared.so
using below CMake configuration:
target_link_libraries( libshaderc-shared
[my-ndk-root]/sources/third_party/shaderc/libs/c++_static/${ANDROID_ABI}/libshaderc.a )
References:
- Here is the guide for how to properly build shaderc https://github.com/google/shaderc.
- https://developer.android.com/ndk/guides/graphics/shader-compilers
Answered By - shizhen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.