我正在尝试在需要Skia的Windows上使用building it from source图形库。但是,当我运行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

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

最佳答案

正如on the Skia google group的回答,如果您缺少某些库,则需要在生成这样的生成文件时传递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

(如果您不知道头文件属于Google搜索属于哪个库,也会有所帮助)

关于c++ - 尝试构建Skia时缺少头文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58287158/

10-09 19:28