3

I'm trying to use the Skia graphics library on Windows which requires building it from source. However, when I run the build command:

ninja -C out/Static

I get this build error:

"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

I tried running it again and now I get a different error:

"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

How do I obtain all these missing files?

Fudge Fudge
  • 1,024
  • 1
  • 10
  • 25

2 Answers2

4

As answered on the Skia google group, if you are missing some libraries, you need to disable the parts that depend on the missing libraries by passing skia_use_foo=false while generating the build files like this:

"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"

Then build normally using

ninja -C out/Static

If you are missing additional libraries find out the syntax to disable them by using

gn args --list out/Static 

(If you don't know what library a header file belongs to a google search will help too)

Fudge Fudge
  • 1,024
  • 1
  • 10
  • 25
3

A few years have passed, maybe the situation has changed, and there are different practices in the official documentation.
First you should run python tools/git-sync-deps to download all dependencies.
Then, if you find that there are still header files that cannot be found during compilation, add the skia_use_system_xxx=false parameter.
Here's the command I use on 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

In this way, you can still compile all dependencies. The only change is that the dependencies are obtained from the place you just downloaded instead of the system path.

pellorao
  • 43
  • 4
  • Thank you for the tip; it saved me a lot of time. The only addition I did was also `skia_use_system_freetype2=false` – Sarpe Feb 28 '23 at 11:31