{"id":13808511,"url":"https://github.com/wingtk/gvsbuild","last_synced_at":"2025-05-14T13:06:38.907Z","repository":{"id":27395499,"uuid":"30871812","full_name":"wingtk/gvsbuild","owner":"wingtk","description":"GTK stack for Windows","archived":false,"fork":false,"pushed_at":"2025-05-13T10:40:08.000Z","size":19818,"stargazers_count":504,"open_issues_count":33,"forks_count":176,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-05-13T11:36:02.547Z","etag":null,"topics":["glib","gtk","visual-studio","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wingtk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-02-16T14:30:08.000Z","updated_at":"2025-05-13T10:38:40.000Z","dependencies_parsed_at":"2024-01-19T19:50:04.187Z","dependency_job_id":"5e75e955-c967-48aa-9a8e-a1741b8dc2a3","html_url":"https://github.com/wingtk/gvsbuild","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingtk%2Fgvsbuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingtk%2Fgvsbuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingtk%2Fgvsbuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingtk%2Fgvsbuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wingtk","download_url":"https://codeload.github.com/wingtk/gvsbuild/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253938845,"owners_count":21987405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["glib","gtk","visual-studio","windows"],"created_at":"2024-08-04T01:01:44.675Z","updated_at":"2025-05-14T13:06:33.895Z","avatar_url":"https://github.com/wingtk.png","language":"C++","readme":"# gvsbuild\r\n\r\n![CI](https://github.com/wingtk/gvsbuild/actions/workflows/ci.yml/badge.svg)\r\n\r\nThis python script helps you build a full [GTK](https://www.gtk.org/) library\r\nstack for Windows using Visual Studio. Currently, GTK 3 and GTK 4 are supported.\r\n\r\n## Install GTK Only\r\n\r\nIf you want to only run GTK on Windows and not build it yourself, you can download\r\na zip file from the [latest release](https://github.com/wingtk/gvsbuild/releases/latest) and unzip it to `C:\\gtk`.\r\n\r\nIt comes with GTK4, Cairo, PyGObject, Pycairo, GtkSourceView5, adwaita-icon-theme, and\r\nall of their dependencies.\r\n\r\nNote however that these binaries are provided “AS IS”, WITHOUT WARRANTY OF ANY KIND.\r\nThey just contain the output of our latest CI run. They are not tested, and we cannot\r\ncommit to timely updates even for security issues. We strongly recommend to build your\r\nown binaries, especially if you plan to distribute them with your application or use them in\r\nproduction.\r\n\r\n### Environmental Variables\r\nFinally, add GTK to your environmental variables with:\r\n\r\n```PowerShell\r\n$env:Path = \"C:\\gtk\\bin;\" + $env:Path\r\n$env:LIB = \"C:\\gtk\\lib;\" + $env:LIB\r\n$env:INCLUDE = \"C:\\gtk\\include;C:\\gtk\\include\\cairo;C:\\gtk\\include\\glib-2.0;C:\\gtk\\include\\gobject-introspection-1.0;C:\\gtk\\lib\\glib-2.0\\include;\" + $env:INCLUDE\r\n```\r\n\r\n### PyGObject and PyCairo\r\n\r\nIf you are going to use PyGObject and Pycairo, you also need to use the gvsbuild\r\ngenerated wheels with your [Python virtualenv](https://docs.python.org/3/tutorial/venv.html)\r\nin order to work around this [PyGObject bug](https://gitlab.gnome.org/GNOME/pygobject/-/issues/545):\r\n\r\n```PowerShell\r\npip install --force-reinstall (Resolve-Path C:\\gtk\\wheels\\PyGObject*.whl)\r\npip install --force-reinstall (Resolve-Path C:\\gtk\\wheels\\pycairo*.whl)\r\n```\r\n\r\n## Build GTK\r\n\r\nThe script supports multiple versions of Visual Studio - at the moment we are\r\nfocusing on VS 2022, but we include projects for other versions, and we gladly\r\naccept patches.\r\n\r\nThe script focuses on GTK and the surrounding ecosystem (e.g. GStreamer).\r\nHowever, we are open to adding more libraries as long as the contributor takes\r\non the responsibility for keeping it up to date. The supported projects are\r\nmodules in the\r\n[projects](https://github.com/wingtk/gvsbuild/blob/master/gvsbuild/projects)\r\ndirectory.\r\n\r\nThe script requires a working installation of [Visual Studio for Windows\r\nDesktop](http://www.visualstudio.com), [Python 3](https://www.python.org) and\r\n[msys2](https://msys2.github.io). The script will download any additional tools\r\nrequired to build the libraries and will use them from a local directory,\r\nwithout any installation. As of today these tools include cmake, meson, ninja,\r\nnuget and perl.\r\n\r\nThe script fetches source tarballs for the projects from their original\r\nlocations, however in some cases it might be necessary to host a patched tarball\r\non GitHub. To ensure integrity of the downloaded files, the script checks the\r\nSHA256 hash of each download. Downloads are done using TLS, using SSL\r\ncertificates provided by the system, but in case of error the download is tried\r\nagain ignoring certificate errors.\r\n\r\nFirst we need to install the prerequisites. There are two main options:\r\n\r\n1. WinGet - Available for Windows 11, and modern versions of Windows 10\r\n2. Chocolately - An alternative for other Windows versions\r\n\r\n### Prerequisites with WinGet\r\n\r\nIf you would prefer to use Chocolately instead of WinGet, you can skip this\r\nsection and follow the Prerequisites with Chocolately steps.\r\n\r\n#### WinGet\r\nWinGet is the Windows Package Manager and is available on Windows 11 and modern\r\nversions of Windows 10 (1809 / build 17763) as a part of the\r\n[App Installer](https://www.microsoft.com/p/app-installer/9nblggh4nns1) package\r\nin the Windows Store.\r\n\r\n#### Git\r\nTo setup a development environment in Windows install\r\n[Git](https://gitforwindows.org) by executing as an administrator:\r\n\r\n```PowerShell\r\nwinget install --id Git.Git -e --source winget\r\n```\r\n\r\n#### MSYS2\r\nBoth of the development environments in the next steps need MSYS2 installed.\r\n\r\nInstall [MSYS2](http://www.msys2.org/):\r\n\r\nKeep PowerShell open as administrator and execute:\r\n```PowerShell\r\nwinget install --id MSYS2.MSYS2 -e --source winget\r\n```\r\n\r\n#### Install Visual Studio 2022\r\nWith your admin PowerShell terminal:\r\n\r\n```PowerShell\r\nwinget install Microsoft.VisualStudio.2022.BuildTools -e --source winget --silent --override \"--wait --quiet --add ProductLang En-us --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended\"\r\n```\r\n\r\nRestart your computer following this installation.\r\n\r\nNote: Visual Studio versions 2013 (not for all projects), 2015, 2017, 2019, and 2022 are currently supported.\r\n\r\n#### Install the Latest Python\r\n\r\nWith your admin PowerShell terminal:\r\n\r\n```PowerShell\r\nwinget install --id Python.Python.3.13 -e --source winget\r\n```\r\n\r\n2. Open a PowerShell terminal as a normal user and check the python version:\r\n\r\n   ```PowerShell\r\n   py -3.13 --version\r\n   ```\r\n\r\n### Prerequisites with Chocolately\r\n\r\nIf you already installed the prerequisites with WinGet, you can skip this section.\r\n\r\n#### Chocolatey\r\nAn alternative to WinGet is using [Chocolately](https://chocolatey.org/) as a package manager\r\nin Windows.\r\n\r\nTo install it, open PowerShell as an administrator, then execute:\r\n\r\n```PowerShell\r\nSet-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))\r\n```\r\nTo run local scripts in follow-on steps, also execute\r\n`Set-ExecutionPolicy RemoteSigned`. This allows for local PowerShell scripts\r\nto run without signing, but still requires signing for remote scripts.\r\n\r\n#### Git\r\nTo setup a development environment in Windows install\r\n[Git](https://gitforwindows.org) by executing as an administrator:\r\n\r\n```PowerShell\r\nchoco install git\r\n```\r\n\r\n#### MSYS2\r\nBoth of the development environments in the next steps need MSYS2 installed.\r\n\r\nInstall [MSYS2](http://www.msys2.org/):\r\n\r\nKeep PowerShell open as administrator and execute:\r\n```PowerShell\r\nchoco install msys2\r\n```\r\n\r\n#### Install Visual Studio 2022\r\nWith your admin PowerShell terminal:\r\n\r\n```PowerShell\r\nchoco install visualstudio2022-workload-vctools\r\n```\r\n\r\nNote: Visual Studio versions 2013 (not for all projects), 2015, 2017, 2019, and 2022 are currently supported.\r\n\r\n#### Install the Latest Python\r\n\r\nWith your admin PowerShell terminal:\r\n\r\n```PowerShell\r\nchoco install python313\r\n```\r\n\r\n2. Open a PowerShell terminal as a normal user and check the python version:\r\n\r\n   ```PowerShell\r\n   py -3.13 --version\r\n   ```\r\n\r\n### Install gvsbuild\r\n\r\nThe recommended way to install gvsbuild is with pipx. Open a new regular user\r\nPowerShell terminal and execute:\r\n\r\n```PowerShell\r\npy -3.13 -m pip install --user pipx\r\npy -3.13 -m pipx ensurepath\r\npipx install gvsbuild\r\n```\r\n\r\nAlternatively, you can also use git to clone the repository and install it.\r\nOpen a new regular user PowerShell terminal and execute:\r\n\r\n```PowerShell\r\nmkdir C:\\gtk-build\\github\r\ncd C:\\gtk-build\\github\r\ngit clone https://github.com/wingtk/gvsbuild.git\r\ncd C:\\gtk-build\\github\\gvsbuild\r\npython -m venv .venv\r\n.\\.venv\\Scripts\\activate.ps1\r\npip install .\r\n```\r\n\r\n### Build GTK\r\n\r\nIn the same PowerShell terminal, execute:\r\n\r\n```PowerShell\r\ngvsbuild build gtk3\r\n```\r\n\r\nAlternatively, if you want to build GTK 4, execute:\r\n```PowerShell\r\ngvsbuild build gtk4\r\n```\r\n\r\nGrab a coffee, the build will take a few minutes to complete.\r\n\r\n### Add GTK to Your Environmental Variables\r\n\r\n1. From the Start menu, go to the Control Panel entry for “Edit environment variables for your account”.\r\n2. Double-click the `Path` row in the top list of variables. Click “New” to add a new item to the list.\r\n3. Paste in `C:\\gtk-build\\gtk\\x64\\release\\bin`\r\n4. Click \"OK\" twice.\r\n\r\nYou are now ready to use GTK!\r\n\r\n### Additional Gvsbuild Usage\r\n\r\n#### Using GTK with Visual Studio\r\n\r\n1. Open Visual Studio and \"Create a new project\" using the \"Empty Project\" template\r\n2. On the left, right click on \"Source Files\" and choose \"Add\", then \"New Item...\" and replace the name with `main.c`\r\n3. Paste in the following contents, then save the file:\r\n\r\n   ```\r\n   #include \u003cgtk/gtk.h\u003e\r\n   \r\n   static void activate_cb(GtkApplication *app) {\r\n     GtkWidget *window = gtk_application_window_new(app);\r\n     gtk_widget_set_visible(window, true);\r\n   }\r\n   \r\n   int main(int argc, char **argv) {\r\n     GtkApplication *app =\r\n         gtk_application_new(\"org.app\", G_APPLICATION_DEFAULT_FLAGS);\r\n     g_signal_connect(app, \"activate\", G_CALLBACK(activate_cb), NULL);\r\n     return g_application_run(G_APPLICATION(app), argc, argv);\r\n   }\r\n   ```\r\n\r\n4. Go to your project's settings by right-clicking and choosing \"Properties\"\r\n\r\n   ![screenshot showing the properties item is at the bottom of the context menu](doc/visual-studio-project-context-menu.png)\r\n\r\n5. On the left, open \"C/C++\", then choose \"Command Line\".\r\n   1. Open \"Powershell\" and run the command `pkg-config --cflags gtk4 --msvc-syntax`\r\n   2. Paste the result into the \"Additional Options\" field at the bottom of the Visual Studio Properties window.\r\n\r\n   ![screenshot showing the \"Additional Options\" field to modify](doc/visual-studio-properties-c-command-line.png)\r\n\r\n6. Still in the Visual Studio window, click on \"Linker\" and choose \"Command Line\". Do the same thing as the last step, except use the output of `pkg-config --libs gtk4 --msvc-syntax`\r\n7. Click \"OK\"\r\n8. In the top menu bar, click \"Debug\" and \"Start Without Debugging\"\r\n\r\n#### Using GTK with Rust\r\n\r\nSee [the fantastic `gtk-rs` book](https://gtk-rs.org/gtk4-rs/stable/latest/book).\r\nYou can skip the \"Install GTK 4\" step, as the above steps ^ covered that.\r\n\r\n#### Use PyGObject\r\n\r\nFirst, add GTK to your environment variables:\r\n\r\n```PowerShell\r\n$env:LIB = \"C:\\gtk-build\\gtk\\x64\\release\\lib;\" + $env:LIB\r\n$env:INCLUDE = \"C:\\gtk-build\\gtk\\x64\\release\\include;C:\\gtk-build\\gtk\\x64\\release\\include\\cairo;C:\\gtk-build\\gtk\\x64\\release\\include\\glib-2.0;C:\\gtk-build\\gtk\\x64\\release\\include\\gobject-introspection-1.0;C:\\gtk-build\\gtk\\x64\\release\\lib\\glib-2.0\\include;\" + $env:INCLUDE\r\n```\r\n\r\nNext, add the `--enable-gi` and `--py-wheel` options like:\r\n\r\n```PowerShell\r\ngvsbuild build --enable-gi --py-wheel gtk4 pygobject\r\n```\r\n\r\nOnce that finishes, then you need to use the gvsbuild generated wheels with your\r\n[Python virtualenv](https://docs.python.org/3/tutorial/venv.html) in order to\r\nwork around this [PyGObject\r\nbug](https://gitlab.gnome.org/GNOME/pygobject/-/issues/545):\r\n\r\n```PowerShell\r\npip install --force-reinstall (Resolve-Path C:\\gtk-build\\build\\x64\\release\\pygobject\\dist\\PyGObject*.whl)\r\npip install --force-reinstall (Resolve-Path C:\\gtk-build\\build\\x64\\release\\pycairo\\dist\\pycairo*.whl)\r\n```\r\n\r\n#### Use Icons with GTK\r\n\r\nIf you are going to use SVG icons with a GTK app, you need to also need to build `librsvg`. Normally you want\r\nto build GTK with `gvsbuild build gtk4 adwaita-icon-theme` which will include librsvg and hicolor-icon-theme.\r\n\r\n#### Other Options\r\n\r\n For more information about the possible commands run:\r\n\r\n ```\r\n gvsbuild --help\r\n ```\r\n\r\n To get detailed help on the build command run:\r\n\r\n ```\r\n gvsbuild build --help\r\n ```\r\n\r\n It is possible to set some parameters from a file, e.g. vs2015-release.pro, putting\r\n the @ character before the file name. The file contains the option, one per\r\n line, separated by a carriage return:\r\n\r\n ```\r\n --vs-ver\r\n 14\r\n --win-sdk\r\n 8.1\r\n --configuration\r\n release\r\n ```\r\n\r\n Even if the format is not the easier to write or read in this way we eliminate\r\n the problem of escaping spaces is file names and directories. Then you can use\r\n it:\r\n\r\n ```\r\n gvsbuild build @vs2015-release.pro gtk3-full\r\n ```\r\n\r\n## Troubleshooting\r\n\r\n- If a build fails, try rebuilding it with `--clean`, if that fails, try\r\nrebuilding it with `--from-scratch`\r\n- If the download of a tarball fails a partial file will not pass the hash check,\r\ndelete the file and try again.\r\n- If you get an out of memory error, reduce the number of processor cores building at once\r\nby adding the `--ninja-opts -j2` option, where 2 is the number of cores.\r\n- If you are getting a C4819 error or warning, this is an issue of Visual Studio running on\r\nCJK (East Asian) locales. Set your system's locale setting for non-Unicode to English\r\n(United States), reboot, and restart the build, and the code should build normally.\r\n\r\n## OpenSSL\r\n\r\nIn addition to the setup instructions above, to build OpenSSL you also need the\r\nVisual C++ 2013 Redistributable Package installed. To install it, open PowerShell\r\nas administrator and execute:\r\n\r\n```PowerShell\r\nchoco install vcredist2013\r\n```\r\n\r\nSimilar to other packages, you can build OpenSSL by executing:\r\n```\r\ngvsbuild build openssl\r\n```\r\n\r\n## Dependency Graph\r\n\r\nTo see and analyze the dependency between the various projects, in text or in a\r\nGraphviz format, use the script deps.py:\r\n\r\n ```\r\ngvsbuild deps --graph --gv-file test.gv\r\n ```\r\n\r\nWithout option a simple dependency of all the projects is printed, as usual with\r\n--help a summary of the options/commands is printed.\r\n\r\n## Gvsbuild Users\r\n\r\nThe following projects are using Gvsbuild for Windows GTK cross-platform support:\r\n\r\n- [Deluge](https://github.com/deluge-torrent/deluge) - BitTorrent client\r\n- [Gaphor](https://github.com/gaphor/gaphor) - A simple SysML/UML modeling tool\r\n- [PothosSDR](https://github.com/pothosware/PothosSDR) - Software-Defined Radio development environment\r\n- [SkyTemple Randomizer](https://github.com/SkyTemple/skytemple-randomizer) - Randomizer for Pokémon Mystery Dungeon Explorers of Sky\r\n\r\nAre you using Gvsbuild? Please submit a Pull Request to add your app to the list.\r\n\r\n## License\r\n\r\nThis build script is licensed under the GPL2.0 license, see the COPYING file for\r\nthe full text.\r\n\r\nThe binaries produced by the build script are licensed under the license terms\r\nof the project that is built (ie glib is LGPL so you can use glib.dll built\r\nwith this script under the terms of LGPL).\r\n\r\nPatches included in the repository are licensed under the license terms of the\r\nproject they apply to.\r\n\r\n## Credits\r\n\r\nThis tool originated from a gtk-win32 PowerShell script created by the\r\n[HexChat](https://hexchat.github.io/) developers for building it for Windows.\r\nAlthough this project is now archived, you can explore the original project if you\r\nare interested in the history at https://github.com/hexchat/gtk-win32.\r\n\r\nCompiling the GTK stack on MSVC would not be possible without the incredible\r\nwork by [Fan Chun-wei](https://github.com/fanc999). If you are interested in more\r\ndetails of how this works, please see [Compiling the GTK+ (and Clutter) stack using\r\nVisual C++ 2008 and\r\nlater](https://wiki.gnome.org/Projects/GTK/Win32/MSVCCompilationOfGTKStack).\r\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwingtk%2Fgvsbuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwingtk%2Fgvsbuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwingtk%2Fgvsbuild/lists"}