How to Build Skia on Windows - c++

I have not yet been able to successfully build skia from source code on Windows 10. I am going in circles at this point.
I followed the official instructions here https://skia.org/user/build but always get errors.
gn args are:
is_official_build=true
is_component_build = false
win_vc="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
skia_use_libpng=false
skia_use_icu=false
skia_use_zlib=false
skia_use_libwebp=false
skia_enable_pdf=false
skia_use_libjpeg_turbo=false
skia_use_expat=false
I get the following error:
C:\Development\skia\bin>ninja -C out/Static
ninja: Entering directory `out/Static'
[13/2662] copy ../../../third_party/externals/icu/common/icudtl.dat icudtl.dat
FAILED: icudtl.dat
python C:/Development/skia/gn/cp.py ../../../third_party/externals/icu/common/icudtl.dat icudtl.dat
CreateProcess failed: The system cannot find the file specified.
ninja: fatal: ReadFile: The handle is invalid.
Any thoughts would be appreciated.
By the way, first attempt at:
using gn or ninja to build anything
using Chromium's depot_tools
So, I am not ruling out any user error on my part :(

Related

Gradle and Cmake failing to find cpp file that is definitely there

I run gradle to build an android .aar and it reports that it can't find a file, but the file definitely is there.
$ ./gradlew.bat assembleRelease
> Task :webrtc-native:externalNativeBuildRelease FAILED
Build mrwebrtc arm64-v8a
ninja: error: 'C:/Developer/Microsoft-MRWebRTC/libs/mrwebrtc/src/interop/data_channel_interop.cpp', needed by 'CMakeFiles/mrwebrtc.dir/C_/Developer/Microsoft-MRWebRTC/libs/mrwebrtc/src/interop/data_channel_interop.cpp.o', missing and no known rule to make it
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':webrtc-native:externalNativeBuildRelease'.
> Build command failed.
Error while executing process C:\Users\User\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe with arguments {--build C:\Developer\Microsoft-MRWebRTC\tools\build\android\webrtc-native\.externalNativeBuild\cmake\release\arm64-v8a --target mrwebrtc}
ninja: error: 'C:/Developer/Microsoft-MRWebRTC/libs/mrwebrtc/src/interop/data_channel_interop.cpp', needed by 'CMakeFiles/mrwebrtc.dir/C_/Developer/Microsoft-MRWebRTC/libs/mrwebrtc/src/interop/data_channel_interop.cpp.o', missing and no known rule to make it
But the file C:/Developer/Microsoft-MRWebRTC/libs/mrwebrtc/src/interop/data_channel_interop.cpp is definitely there.
$ cd C:/Developer/Microsoft-MRWebRTC/libs/mrwebrtc/src/interop/
User MSYS /c/Developer/Microsoft-MRWebRTC/libs/mrwebrtc/src/interop (master)
$ ls
data_channel_interop.cpp global_factory.cpp interop_api.cpp local_video_track_interop.cpp remote_audio_track_interop.cpp transceiver_interop.cpp
external_video_track_source_interop.cpp global_factory.h local_audio_track_interop.cpp peer_connection_interop.cpp remote_video_track_interop.cpp
Could anyone help? I am kind of running out of ideas on this.
I discovered it was because I had 'caseSensitive' flags enabled on some of my directories. Be careful, this is a new feature of WSL2 and there are some peculiarities where you may be enabled in without realizing. Windows cmake cannot traverse directories that have this flag enabled on them.
Read about it here:
https://devblogs.microsoft.com/commandline/per-directory-case-sensitivity-and-wsl/

lld-link: error: <root>: undefined symbol: mainCRTStartup when building V8

I've spent a whole day on this now and I can't seem to get the .lib files to build with VS 2017. I followed the V8 docs here:
https://v8.dev/docs/build
Following the instructions does work, but I end up with a V8 command line program in the out directory and .lib that do NOT work with Visual Studio 2017.
fatal error LNK1107: invalid or corrupt file: cannot read at 0x1422A
I executed this to try to get the build files for the libraries only:
gn gen out/lib --args="v8_static_library=true v8_use_snapshot=true v8_use_external_startup_data=false v8_monolithic=true icu_use_data_file=false is_component_build=false is_debug=false"
Then ran this: ninja -C out/lib
And this was the final result:
ninja: Entering directory `out/lib'
[1632/1645] LINK cctest.exe cctest.exe.pdb
FAILED: cctest.exe cctest.exe.pdb
ninja -t msvc -e environment.x64 -- ../../../../third_party/llvm-build/Release+Asserts/bin/lld-link.exe /nologo /OUT:./cctest.exe /PDB:./cctest.exe.pdb #./cctest.exe.rsp
lld-link: error: <root>: undefined symbol: mainCRTStartup
[1634/1645] LINK generate-bytecode-expectations.exe generate-bytecode-expectations.exe.pdb
ninja: build stopped: subcommand failed.
I think I'm missing something, but I have no idea at the moment.
Ok, seems my first mistake was changing the prompt to v8\tools\dev\ and working from there. The "normal" steps I found actually only work properly from the root of the source. I ended up with v8\tools\dev\out\x64.release then ninja -C out/x64.release v8 failed because v8 was not accepted in this setup for some reason.
The other thing I did wrong was to edit the args.gn file directly and save it. The CORRECT process is to run gn args out.gn\x64.release so that after you save AND close the editor, it automatically re-generates/updates the files. Most likely changing the file has no effect on its own, and you'll get confused because ninja won't even see the changes.
The linker error about corrupt files is because is_clang is true by default. Setting is_clang=false fixes that error. It just works, I have no idea why; just take it and go ... ;)
The correct way, from the root that worked for me is:
python tools\dev\v8gen.py x64.release
python tools\dev\v8gen.py ia32.release
python tools\dev\v8gen.py x64.debug
python tools\dev\v8gen.py ia32.debug
This will output files that can be compiled in the "v8\out.gn" folder.
Tip: Run "python tools\dev\v8gen.py list" to see a list of possible build configurations.
Next I updated the build arguments:
gn args out.gn\x64.release
Using these:
is_debug = false <-(or true for debug builds)
target_cpu = "x64"
is_component_build = false
v8_static_library = true
use_custom_libcxx = false
use_custom_libcxx_for_host = false
v8_use_external_startup_data = false <-(or true to use the bin startup files)
is_clang = false
And again for the 32-bit version (changing "x64" above to "x86" of course):
gn args out.gn\ia32.release
Then repeated all the above for x64.debug and ia32.debug.
And compiled them:
ninja -C out.gn/x64.debug v8
ninja -C out.gn/ia32.debug v8
ninja -C out.gn/x64.release v8
ninja -C out.gn/ia32.release v8
Visual Studio 2017 now builds and links my project against them again now (was an old project I resurrected).
Note: Linking against debug versions of V8 libraries may give an error that _ITERATOR_DEBUG_LEVEL does not match. To fix this I simply went to the C++ project settings (Confiuration Properties->C/C++->Preprocessor->Preprocesor Definitions) and added ;_ITERATOR_DEBUG_LEVEL=0 so it matches.

*** internal error: unable to open jobserver semaphore '3,4': (Error 2: The system cannot find the file specified. ). Stop

I am trying to compile an existing qt application's code using mingw compiler.
During compilation I am getting an error "*** internal error: unable to open jobserver semaphore '3,4': (Error 2: The system cannot find the file specified. ). Stop".
My current project is a makefile based project. Here I have one make file (parent.mk) that compiles all primary modules and then
parent.mk
compilation steps
.
.
.
make $QT_CODE_DIR
Here in this QT code directory I have another makefile (child.mk) which has following content:
child.mk
cd "qtcode_compilation_out_dir"
qmake.exe "product.pro" -r -spec win32-g++
CONFIG+=release
mingw32-make -w
If I try to run the make command manually for QT code then it works fine.
#Alexander: Thanks for the suggestion.
Please suggest if anyone has any idea about it.
Thanks.
Finally, I found out the exact reason of the problem and solution as well.
Reason for failure:
The compilation command that I am using is "make" which is been aliased to "make -j2"and along with "mingw32-make -w" it was producing the error because mingw32-make is an obsolete make command and it doesn't support multi threaded compilation.
Solution:
I just replaced the mingw32-make with make.

LNK1181 error when compiling V8 engine on Win10

I'm following this guide on building V8 but I am hitting some issues on the compilation step. I am running Windows 10 x64. I am trying to compile with options to embed the engine also.
Running the following command:
ninja -C out.gn/x64.release
Gives me this error:
ninja: Entering directory `out.gn/x64.release'
[1/471] LINK mksnapshot.exe mksnapshot.exe.pdb
FAILED: mksnapshot.exe mksnapshot.exe.pdb
C:/Workspace/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./mksnapshot.exe /PDB:./mksnapshot.exe.pdb #./mksnapshot.exe.rsp
LINK : fatal error LNK1181: cannot open input file 'comdlg32.lib'
ninja: build stopped: subcommand failed.
Now I believe I have narrowed down the error to looking for the .lib files in the wrong directory. I have (had) multiple versions installed, so there were multiple folders in my Windows Kit install.
Windows Kits/10/Lib/10.0.16299.0
Windows Kits/10/Lib/10.0.15xxx.0
If I dragged and dropped the comdlg32.lib file from 10.0.16299.0 into the 10.0.15xxx.0 directory then the error changed to a LNK1181 error with a different input file. I did this a few times but I was unsure if this was going to cause issues with different versions and there was probably going to be a lot.
I uninstalled the 10.0.15xxx.0 version which left behind the folder I mentioned, so I removed that and after doing so I have started getting the LNK1181 error with a different input file (advapi32.lib I assume the very first file it can't find). This is how I came to the conclusion about the path being incorrect.
So I have tried a few things to change the path (I hoped just uninstalling the old version would fix it) such as:
Uninstalling the old version.
Going through registry entries to see if I can find an install path or something using that path, which I didn't. I did notice that there was still installation and data in the registry for the 10.0.15xxx.0 install, I might try deleting that from the registry directly as a last resort?
I have tried to explicitly set the path by setting <TargetUniversalCRTVersion>10.0.16299.0</TargetUniversalCRTVersion> in this file: C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\uCRT.props
I have never used Ninja before so I tried looking for a way to set some kind of lib-path in the command but couldn't really find anything.
I looked through the python scripts being executed to try and locate something to do with the libs path but couldn't see anything.
I would be grateful for any help and suggestions. Thanks.
You can try to compile v8 using Visual Studio as explained here: https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#using-the-visual-studio-ide
By running the following commands:
$ gn gen --ide=vs out.gn/x64.release
$ cd out.gn/x64.release
$ msbuild all.sln
You can see a full example here: https://github.com/phpv8/v8js/issues/272#issuecomment-262848754
Apparently this method is not officially supported anymore, but I had the same problem as you have and this solved the issue for me.
Note that after this I had another issue, the unit tests failed to be compiled due to a linking error, but I had the necessary libraries to use v8. So there may be deeper problem that is causing all of this that I'm missing.
Edit:
Also, you could try to set the following parameters with gn args:
visual_studio_path = "..."
visual_studio_version = "2017"
wdk_path = "..."
windows_sdk_path = "C:\Program Files (x86)\Windows Kits\10"
To set those parameters, do:
gn args out.gn/x64.release
This will open a text editor where you can write the extra parameters you are interested in.
To see the full list of parameters you can specify:
gn args --list out.gn/x64.release
I was following this guide https://medium.com/dailyjs/how-to-build-v8-on-windows-and-not-go-mad-6347c69aacd4 and also ran into the error
LINK1181: cannot open input file 'advapi32.lib'
I'm pretty sure it was because I had the wrong versions of the Windows 10 SDK. Similar to you I had versions:
Windows Kits/10/Lib/10.0.10240.0
Windows Kits/10/Lib/10.0.16299.0
But according to https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#Setting-up-Windows (Which I think is relevant) you need version 10.0.15063.0
After installing version 10.0.15063.0 (with the visual studio installer) to
Windows Kits/10/Lib/10.0.15063.0
I was able to continue with the build.

Chromium build failed (Windows 10)

Good afternoon. Tell me who build Chromium om Windows. It is required to brand Chromium (start page, bookmarks, tray icons, name), collect according to the instructions at the site chromium. When assembling through VS 2015, the following error list appears. The assembly takes place on the server, 64 GB RAM, Intel Xeon.
The compilation goes to 60-70%, after which VS crashes, restarts and gives an error: "The following files can not be found - all.sln - so they will not be loaded" - after this error the assembly stops, I tried 10 times already.
Ninja: build stopped: subcommand failed. Warning: premature end of file; Recovering
FAILED: obj / third_party / yasm / yasm_utils / xmalloc.obj
First, try running the build from command line:
ninja -C src/out/Default
If it still fails, make sure you carefully followed prerequisites installation instructions. Specifically, try gclient sync -f and make sure it finished normally before building.