Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Installing on Windows

Josh Rickmar edited this page Jan 11, 2014 · 18 revisions

Installing gotk3 on Windows will likely be a bit more involved than Unix(-like) environments since GTK is probably not already installed. These instructions, tested on a 64-bit Windows 8.1 installation, detail how to set up a build environment to install and use gotk3 from a base Windows installation.

Install 7-zip

The first step for installing gotk3 on Windows is to install 7-zip as it is needed to extract the RPM packages for GTK and dependencies later.

Install MinGW-w64

The next step is to install MinGW-w64. Download the installer from here. These instructions are tested with version 4.8.1.

Install git

If you haven't already, be sure to install Git for Windows. The Windows version includes a bash shell and several useful Unix command line utilities, which are required.

Install GTK and dependencies

gotk3 on Windows was tested and compiled using Fedora Core 20 mingw64 packages. The following packages must be downloaded:

  • atk
  • cairo
  • expat
  • fontconfig
  • freetype
  • gdk-pixbuf
  • gettext
  • glib2
  • gtk3
  • harfbuzz
  • libffi
  • libpng
  • pango
  • pixman
  • win-iconv
  • zlib

Double check to be sure you have downloaded the mingw64 packages. mingw32 packages will not work.

After each package has been downloaded, create the directory C:\Fedora\ where these files will be extracted to. In the directory where you downloaded the above packages, right click on a RPM and select "7-Zip -> Open archive". This will open and let you browse the RPM in 7-Zip. Use the 7-Zip browser to navigate to mingw64-pkgname-version.fc20.noarch.cpio\.\usr\x86_64-w64-mingw32\sys-root\mingw\. You should see several directories that look like they came from the root directory of a Unix (bin, include, lib, share, etc.). Select these folders and drag them to an explorer window opened to C:\Fedora to extract the package contents. (Note: on Windows 7 a dialog will be opened prompting you how to proceed with the copy. Select merge and tick the checkbox to perform the action on all files.)

Install pkg-config

A Win64 pkg-config binary will be necessary to build gotk3. Get this by downloading the pkg-config zip from here. Using 7-Zip, extract the zip and copy pkg-config.exe to C:\Fedora\bin.

Modify your pkg-config scripts

The default pkg-config files are written to reference the installation location for the Fedora RPM packages on Fedora, and as such, must be modified to reference their location on Windows. Using the git bash shell, cd to C:\Fedora\lib\pkgconfig and run the following sed command:

sed -i.bak 's|/usr/x86_64-w64-mingw32/sys-root/mingw|C:/Fedora|g' *.pc

This will create backups of every pkg-config file (with a .bak suffix), and edit the files in place to use the correct paths.

Finally, the pkg-config scripts from the libpng package must be modified a bit more. The Fedora package symlinks libpng.pc to libpng16.pc, and as Windows does not support symlinks, the libpng.pc file is broken. To fix this, use explorer to delete libpng.pc, make a copy of libpng16.pc, and rename the copy to libpng.pc.

Modify your environment variables

The System Properties window must be opened to modify user and system environment variables. Opening this window varies slightly between Windows 7 and 8.

  • Windows 7: From the Start Menu, right click Computer, and select Properties. Click the 'Advanced system settings' link at the left, and then click the button labeled 'Environment Variables...'.

  • Windows 8: Right click the lower left corner (on Windows 8.1 this is the 'Start Screen' button) and select `System'. Click the 'Advanced system settings' link at the left, and then click the button labeled 'Environment Variables...'.

If this is a fresh Go installation and GOPATH has not been created, do so now:

mkdir -p ~/src/go

To set the GOPATH environment variable, click New from the 'Environment Variables' window. In the dialog that opens, enter GOPATH for the variable name, and %USERPROFILE%\src\go for the value.

The Path environment variable must also be modified to include the folders containing mingw-w64 and Fedora binaries and DLLs. Modify the System Path variable by appending the string ;C:\Fedora\bin;C:\Program Files\mingw-builds\x64-4.8.1-posix-seh-rev5\mingw64\bin (the leading semicolon is to delimit the path from previous paths).

The changes made to the environment variables do not take effect immediately. On Windows 7, close and reopen all cmd.exe or git shell windows for the new environment variable changes to take effect. Windows 8 has changed this to require signing out and back in before any changes to the environment variables take effect.

Test pkg-config

If the above steps were successful, you should be able to use pkg-config from the command line to get a meaningful set of compiler flags. From a git bash shell, run:

pkg-config --cflags --libs gtk+-3.0

pkg-config

If the output looks correct, continue on to the next step.

Go get gotk3

With a compiler toolchain (MinGW-w64), pkg-config, and GTK with all dependencies installed, you should finally have a working build environment to install gotk3. From git bash, run:

go get github.com/conformal/gotk3/gtk

If the above finished without outputting any errors, the install was successful.

Try an example

To be sure all the needed DLLs are installed, try running the examples provided as part of the gtk package. Navigate to $GOPATH/src/github.com/conformal/gotk3/gtk/examples/ and try building each example with go build and then running the generated .exe. If all works fine, your gotk3 install should be ready for developing your own applications.

Grid Example

Congratulations, you have successfully installed gotk3 on Windows. Happy hacking!

Known Issues

  • The Fedora Core 20 packages are missing the 'hicolor' icons for GTK 3.10.