Search code examples
c++windowsskia

Error build skia: machine type x64 conflicts with x86


I'm trying to build Skia as per the instructions here https://skia.org/docs/user/build/. I install the C++ clang tools for Windows using the Visual Studio Installer and then configured skia as follows:

bin/gn gen out/Shared --args='clang_win="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm" is_component_build=true is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_system_icu=false skia_use_system_harfbuzz=false target_cpu="x64"'

Then I ran ninja -C out/Shared but during the build process I get the following error:

FAILED: skia.dll skia.dll.lib skia.dll.pdb
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm/bin/lld-link.exe" /nologo /IMPLIB:./skia.dll.lib /DLL /OUT:./skia.dll /PDB:./skia.dll.pdb @./skia.dll.rsp
lld-link: error: libcmt.lib(std_type_info_static.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(chkstk.obj): machine type x64 conflicts with x86
lld-link: error: libcpmt.lib(locale0.obj): machine type x64 conflicts with x86
lld-link: error: libcpmt.lib(thread0.obj): machine type x64 conflicts with x86
lld-link: error: libcpmt.lib(xthrow.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(delete_scalar_size.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(new_scalar.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(utility.obj): machine type x64 conflicts with x86
lld-link: error: libcpmt.lib(xlock.obj): machine type x64 conflicts with x86
lld-link: error: libcpmt.lib(locale.obj): machine type x64 conflicts with x86
lld-link: error: libcpmt.lib(iosptrs.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(guard_support.obj): machine type x64 conflicts with x86
lld-link: error: libcpmt.lib(syserror.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(gshandler.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(gshandlereh4.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(amdsecgs.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(gs_cookie.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(delete_scalar.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(throw_bad_alloc.obj): machine type x64 conflicts with x86
lld-link: error: libcmt.lib(cpu_disp.obj): machine type x64 conflicts with x86
lld-link: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)
ninja: build stopped: subcommand failed.

I'm running a 64bit version of Windows 11. Anyone have any idea on what the issue might be?


Solution

  • Ok so it turns out that for some reason (not sure what), Skia has a problem with the LLVM version installed using the Visual Studio Installer. I downloaded LLVM directly from their official website and then ran:

    bin/gn gen out/Shared --args='clang_win="C:\Program Files\LLVM" is_component_build=true is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_system_icu=false skia_use_system_harfbuzz=false target_cpu="x64"'

    Running this Skia builds without any errors.