.Net 7.0 AOT /usr/bin/ld: cannot find -lz

命令:

sudo dotnet publish -c Release

报错内容:
MSBuild version 17.4.0+18d5aef85 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
oschina2022 -> /mnt/d/GitHub/oschina2022/oschina2022/bin/Release/net7.0/linux-x64/oschina2022.dll
/usr/bin/ld: cannot find -lz
collect2 : error : ld returned 1 exit status [/mnt/d/GitHub/oschina2022/oschina2022/oschina2022.csproj]
/usr/share/dotnet/sdk/7.0.101/Sdks/Microsoft.DotNet.ILCompiler/build/Microsoft.NETCore.Native.targets(346,5): error MSB3073: The command ""gcc" "obj/Release/net7.0/linux-x64/native/oschina2022.o" -o "bin/Release/net7.0/linux-x64/native/oschina2022" /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/sdk/libbootstrapper.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/sdk/libRuntime.WorkstationGC.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Globalization.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.IO.Compression.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Net.Security.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread -lstdc++ -ldl -lm -lz -lrt -pie -Wl,-z,relro -Wl,-z,now -Wl,--discard-all -Wl,--gc-sections" exited with code 1. [/mnt/d/GitHub/oschina2022/oschina2022/oschina2022.csproj]

解决方法:

sudo apt-get install zlib1g-dev

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值