Skip to content

Instantly share code, notes, and snippets.

@vnl
Last active August 9, 2023 07:56
Show Gist options
  • Save vnl/f317840bfa9c638a60f2c4110872056a to your computer and use it in GitHub Desktop.
Save vnl/f317840bfa9c638a60f2c4110872056a to your computer and use it in GitHub Desktop.
##### Building Google breakpad
Building Google breakpad on Windows is a very painful experience because the process is not really well documented and, furthermore, building the project on Windows is maintained surprisingly poorly by Google. But don't lose hope, it is still possible to build this thing and here are the instructions:
```
git clone https://chromium.googlesource.com/breakpad/breakpad
cd breakpad
git checkout chrome_64
cd src
git clone https://github.com/google/googletest.git testing
cd ..\..
git clone https://chromium.googlesource.com/external/gyp
cd gyp
python setup.py install
cd ..\breakpad
md installdir
md installdir\include\breakpad\client\windows
md installdir\include\breakpad\common\windows
md installdir\lib
md installdir\bin
xcopy src installdir\include\breakpad /e
```
The last line from the above copies almost entire sources of breakpad into the installation prefix's include folder. That might be overkill but hand picking the headers which really need to be present there is too much trouble so this simple hack works.
At this point you need to patch the gyp project file to make breakpad buildable on Windows. You can either do it by hand using any text editor or using `sed` from `msys64`: within "breakpad/src/build" folder there's a file called `common.gypi`. Inside this file you need to replace all occurrences of `'WarnAsError': 'true'` with `'WarnAsError': 'false'`. This setting controls whether the compiler would treat warnings as build errors or not. Some warnings do exist when building on Windows so in the default configuration the build can't succeed. Here's how this setting can be changed with the help of sed editor:
```
C:\msys64\usr\bin\bash -lc "cd /c/dev/breakpad/src/build && sed -i -e \"s/'WarnAsError': 'true'/'WarnAsError': 'false'/g\" common.gypi"
```
Replace the path to breakpad dir with your actual one in the above command.
Now can proceed building the breakpad. Will start from the client libraries and will do two builds, in release and debug configurations:
```
..\gyp\gyp.bat src\client\windows\breakpad_client.gyp --no-circular-check -Dwin_release_RuntimeLibrary=2 -Dwin_debug_RuntimeLibrary=3
cd src\client\windows
msbuild breakpad_client.sln /p:Configuration="Release" /p:Platform="Win32"
msbuild breakpad_client.sln /p:Configuration="Debug" /p:Platform="Win32"
```
For 64 bit build set the "Platform" parameter to "x64". The built release binaries can be found within Release/lib folder and debug ones within Debug/lib one. Copy them to the installation dir while adding the `\_d` suffix for debug libraries:
```
copy Release\lib\common.lib ..\..\..\installdir\lib
copy Release\lib\crash_generation_client.lib ..\..\..\installdir\lib
copy Release\lib\crash_generation_server.lib ..\..\..\installdir\lib
copy Release\lib\exception_handler.lib ..\..\..\installdir\lib
copy Debug\lib\common.lib ..\..\..\installdir\lib\common_d.lib
copy Debug\lib\crash_generation_client.lib ..\..\..\installdir\lib\crash_generation_client_d.lib
copy Debug\lib\crash_generation_server.lib ..\..\..\installdir\lib\crash_generation_server_d.lib
copy Debug\lib\exception_handler.lib ..\..\..\installdir\lib\exception_handler_d.lib
```
Now need to build `dump_syms` utility which would then be used during the build of Quentier for the extraction of symbols from Quentier executable and libquentier library - these symbols would then be used to produce stack traces during crash handling. The end users would then be able to provide the stack traces while reporting crashes - these can be used as minimal hints to the reason of the crash. Without crash handling every single crash is like a shot in the dark - you can't say who did it or why.
```
cd ..\..\..
..\gyp\gyp.bat src\tools\windows\tools_windows.gyp --no-circular-check -Dwin_release_RuntimeLibrary=2 -Dwin_debug_RuntimeLibrary=3
cd src\tools\windows
msbuild tools_windows.sln /p:Configuration="Release" /p:Platform="Win32"
```
After it's built copy it to the installation prefix's bin directory:
```
copy Release\dump_syms.exe ..\..\..\installdir\bin
```
The final touch: need one other executable, `minidump_stackwalk`. It is the executable which parses the minidump produced by the crashing app using the symbols created by `dump_syms`. It seems Google has never planned for this executable to be used - or even built - on Windows because currently the only way to build this tool on Windows is using Cygwin (thus depending on its dlls). Thankfully, guys from Mozilla have already done that so this tool can just be downloaded from Mozilla servers:
```
curl -fsSL http://hg.mozilla.org/build/tools/raw-file/755e58ebc9d4/breakpad/win32/minidump_stackwalk.exe -o minidump_stackwalk.exe
curl -fsSL http://hg.mozilla.org/build/tools/raw-file/755e58ebc9d4/breakpad/win32/cygwin1.dll -o cygwin1.dll
curl -fsSL http://hg.mozilla.org/build/tools/raw-file/755e58ebc9d4/breakpad/win32/cygstdc++-6.dll -o cygstdc++-6.dll
curl -fsSL http://hg.mozilla.org/build/tools/raw-file/755e58ebc9d4/breakpad/win32/cyggcc_s-1.dll -o cyggcc_s-1.dll
```
If you feel inclined, in [this thread](https://groups.google.com/forum/#!topic/google-breakpad-discuss/B4xza0jGdlY) some guy describes what to change in breakpad sources to make `minidump_stackwalk` utility buildable on Windows with Visual C++. You can follow this description to try and build `minidump_stackwalk` on Windows with Visual C++.
That was the last dependency so the guide for building Quentier and/or libquentier dependencies on Windows using Visual Studio is finished now!
@vnl
Copy link
Author

vnl commented Aug 9, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment