You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vulkan API Samples编译失败求助:NDK r17构建报错解决方案

解决Android NDK编译Vulkan示例时的shaderc析构器错误

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:

  1. The shaderc::CompileOptions::IncluderInterface abstract class in NDK r17 lacks a virtual destructor—a C++ requirement for base classes designed to be inherited.
  2. Your build has -Werror enabled (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, set ndk.dir=/path/to/your/new/ndk
    • Or in your module's build.gradle, add ndkVersion "your-new-version" inside the android block

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 the vsamputils target)
  • 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:32:56