Skip to content

Building on Windows

l1n3n01z edited this page Nov 6, 2013 · 23 revisions

This article is a stub and is based on the discussion in #119!

NB: gopy currently fails very badly on Windows, so do NOT expect to have working or even fully built code after following these instructions. We are working on solutions.

TODO: all of this installation is quite polluting. It should be possible to keep it all in one directory, and use bat files to set correct paths and variables etc before building. TODO? Explain why glib and glib-dev are needed? TODO: It should be possible to build in 64 bit at a later time, but first priority is getting 32 bit build working. Qt5 could be skipped altogether, it's also possible to use a prebuilt qt5 binary for 64 bits and mingw-64 has been used successfully to build other go projects that interface with C libraries.

Building on windows requires mingw, currently it is only possible to use 32 bit version of mingw for qt5, so for now we are confined to 32 bit setup, even on 64 bit Windows.

MingW

Qt5 (optional)

Go

Environment Variable

  • set GOARCH=386
  • set CPATH=C:\MinGW\include;C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include;C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore\5.1.1\QtCore
  • set LIBRARY_PATH=C:\MinGW\lib;C:\Qt\Qt5.1.1\5.1.1\mingw48_32\lib
  • set PATH=C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin;C:\MinGW\bin;%path% (!important, put Qt's path in front of MinGW's path otherwise it'll complain libstdc++-6.dll missing as Qt's path contains a different libstd++-6.dll)

Python3

$ mount c:/mingw32 /mingw
$ pexports /c/Windows/SysWOW64/python33.dll >py33.def
$ dlltool -D python33.dll -d py33.def -l libpython33.a
$ cp libpython33.a c:/mingw/lib

libffi

$ mount c:/mingw32 /mingw
$ ./configure --prefix=/mingw
$ make
$ make install

Change cgo.go (lime/3rdparty/libs/gopy/lib/cgo.go)

TODO: Supposedly it's possible to have flags per architecture in #cgo directives. This would simplify the build

package py

// #cgo CFLAGS: -Ic:/python33/include
// #cgo LDFLAGS: -Lc:/Python33/libs -Lc:/mingw/lib -ldl -lpython33
// #cgo pkg-config: libffi
import "C"

Run go test from gopy as stated in regular build instructions. As gopy tests fail badly on windows, this as far as we can go currently. Stay tuned!