Vulkan API Samples编译失败求助:NDK r17构建报错解决方案
Hey there, I know how critical this is for your thesis—let's fix this build error right away. First, let's recap your setup to make sure we're on the same page:
- Ubuntu 14.04
- Android Studio 3.1.2
- NDK r17
- Compile SDK: API 24 (Android 7.0)
- Gradle 3.3
错误核心原因
The error you're hitting boils down to this critical line:
error: delete called on 'shaderc::CompileOptions::IncluderInterface' that is abstract but has non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
Here's why this is happening:
- The
shaderc::CompileOptions::IncluderInterfaceabstract class in NDK r17 lacks a virtual destructor—a C++ requirement for base classes designed to be inherited. - Your build has
-Werrorenabled (visible in the compile flags), which elevates this compiler warning to a fatal build error.
解决方案
1. 升级NDK(推荐长期修复)
NDK r17 is quite outdated, and Google fixed this shaderc bug in later releases (starting from r18 or newer). Here's how to update:
- Open Android Studio, navigate to Tools > SDK Manager > SDK Tools
- Check Show Package Details, then select a stable, newer NDK version (like r21e, which works well with Android Studio 3.1.2)
- Download the new NDK, then update your project's reference:
- In
local.properties, setndk.dir=/path/to/your/new/ndk - Or in your module's
build.gradle, addndkVersion "your-new-version"inside theandroidblock
- In
2. 临时禁用该警告(快速应急方案)
If you can't upgrade NDK right now, you can suppress this specific warning from breaking your build:
- Open your project's
CMakeLists.txt(the one linked to thevsamputilstarget) - Add one of these lines to adjust the compile flags:
# Apply only to the vsamputils target (cleaner approach) target_compile_options(vsamputils PRIVATE -Wno-error=delete-non-virtual-dtor) # Or apply globally to all targets (less recommended, but faster) # add_compile_options(-Wno-error=delete-non-virtual-dtor) - Sync your project and rebuild
This will let the compiler ignore this specific issue while you wrap up your thesis work, but remember to upgrade NDK long-term to avoid other potential bugs.
验证
After applying either fix, try rebuilding the vulkan_sample target again. The error should disappear, and your build should complete successfully.
内容的提问来源于stack exchange,提问作者Sophour

