windows 尝试构建Skia时缺少头文件

ct3nt3jp  于 2023-02-05  发布在  Windows
关注(0)|答案(2)|浏览(96)

我尝试在Windows上使用Skia图形库,但运行build命令时:

ninja -C out/Static

我得到这个构建错误:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe" /nologo /showIncludes /FC -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DNDEBUG -DSK_GAMMA_APPLY_TO_A8 -DSKIA_IMPLEMENTATION=1 -DSK_HAS_PNG_LIBRARY "-IC:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/include" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/shared" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/ucrt" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/winrt" -I../.. /bigobj /utf-8 /O2 /Zc:inline  /GR- /c ../../src/codec/SkPngCodec.cpp /Foobj/src/codec/png.SkPngCodec.obj /Fd"obj/png_c.pdb"
path\to\skia\src\codec\SkPngCodec.cpp(25): fatal error C1083: Cannot open include file: 'png.h': No such file or directory

我尝试再次运行它,现在我得到一个不同的错误:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe" /nologo /showIncludes /FC -DSK_PDF_USE_SFNTLY -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DNDEBUG -DSK_GAMMA_APPLY_TO_A8 -DSKIA_IMPLEMENTATION=1 -DSK_SUPPORT_PDF -DSK_HAS_JPEG_LIBRARY -DU_USING_ICU_NAMESPACE=0 "-IC:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/include" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/shared" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/ucrt" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um" "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/winrt" -I../.. -I../../third_party/externals/sfntly/cpp/src /bigobj /utf-8 /O2 /Zc:inline  /GR- /c ../../src/pdf/SkDeflate.cpp /Foobj/src/pdf/pdf.SkDeflate.obj /Fd"obj/pdf_c.pdb"
C:\Users\natan\Desktop\skia\src\pdf\SkDeflate.cpp(16): fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory

我如何获得所有这些丢失的文件?

sr4lhrrt

sr4lhrrt1#

正如Skia google组中的回答,如果您缺少一些库,您需要在生成构建文件时通过传递skia_use_foo=false来禁用依赖于缺少的库的部分,如下所示:

"bin/gn.exe" gen out/Static --args="is_official_build=true skia_use_libpng=false skia_use_zlib = false skia_use_libjpeg_turbo=false skia_use_harfbuzz=false skia_use_libwebp=false skia_use_expat=false"

然后使用正常生成

ninja -C out/Static

如果缺少其他库,请使用以下命令查找禁用它们的语法

gn args --list out/Static

(If你不知道头文件属于哪个库,谷歌搜索也会有帮助)

9njqaruj

9njqaruj2#

几年过去了,也许情况发生了变化,正式文件中出现了不同的做法。
首先,您应该运行python tools/git-sync-deps来下载所有依赖项。
然后,如果您发现在编译过程中仍然有头文件找不到,请添加skia_use_system_xxx=false参数。
下面是我在Windows上使用的命令:

bin/gn gen out/Static --args='is_official_build=true skia_use_system_libjpeg_turbo=false skia_use_system_zlib=false skia_use_system_harfbuzz=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_expat=false skia_use_system_icu=false'
ninja -C out/Static

这样,你仍然可以编译所有的依赖项,唯一的变化是依赖项是从你刚下载的地方而不是系统路径获取的。

相关问题