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

如何在Debian 10(buster)中运行SkiaSharp 3.116.1版本

解决Debian 10(buster)中SkiaSharp 3.116.1的运行问题

问题背景

Debian 10(buster)服务器上运行ASP.NET 9 MVC应用,该应用依赖DNTCaptcha.Core NuGet包,其最新版本要求SkiaSharp 3.116.1(对应SkiaSharp.NativeAssets.Linux.NoDependencies 3.116.1)。升级至SkiaSharp 3.116.1后,应用启动时抛出如下错误:

System.TypeInitializationException: The type initializer for 'SkiaSharp.SKData' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /var/www/myapp/libSkiaSharp.so)
libSkiaSharp.so: cannot open shared object file: No such file or directory
/var/www/myapp/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/var/www/myapp/libSkiaSharp: cannot open shared object file: No such file or directory
/var/www/myapp/liblibSkiaSharp: cannot open shared object file: No such file or directory

at SkiaSharp.SkiaApi.sk_data_new_empty()
at SkiaSharp.SkiaApi.sk_data_new_empty() at SkiaSharp.SKData..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKData.Create(IntPtr address, Int32 length)
at SkiaSharp.SKBitmap.Decode(ReadOnlySpan`1 buffer)
at SkiaSharp.SKBitmap.Decode(Byte[] buffer)
....

SkiaSharp 3.116.0版本可正常运行,需解决Debian 10环境下SkiaSharp 3.116.1的兼容问题。

核心原因

Debian 10(buster)默认搭载glibc 2.28版本,而SkiaSharp 3.116.1的预编译库依赖glibc 2.29,版本不匹配导致加载失败。

可行解决方案

方案1:手动编译适配Debian 10的SkiaSharp本地库

  • 克隆SkiaSharp源码仓库,切换到3.116.1标签版本
  • 在Debian 10环境安装编译依赖:
    sudo apt-get install build-essential cmake git python3 -y
    
  • 执行官方编译脚本,指定目标系统为Debian 10,确保编译时链接系统自带的glibc 2.28
  • 将编译生成的libSkiaSharp.so替换至ASP.NET应用的发布目录

方案2:替换为兼容低版本glibc的预编译库

放弃使用官方的SkiaSharp.NativeAssets.Linux.NoDependencies包,寻找社区提供的、适配glibc 2.28的SkiaSharp 3.116.1本地库,将其放置到应用目录中替代原文件。

方案3:升级系统至Debian 11(bullseye)

Debian 11默认搭载glibc 2.31,满足SkiaSharp 3.116.1的依赖要求,步骤如下:

  1. 备份服务器数据
  2. 执行系统升级命令:
    sudo apt update && sudo apt upgrade -y
    sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list
    sudo apt update && sudo apt full-upgrade -y
    sudo reboot
    
  3. 系统重启后重新发布应用即可正常运行

方案4:降级DNTCaptcha.Core版本

若无需DNTCaptcha.Core的最新功能,可降级到依赖SkiaSharp 3.116.0的版本,维持应用正常运行,待服务器升级后再更新依赖。

内容的提问来源于stack exchange,提问作者Andrus

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 09:47:16