From 018ff935e6ad8753b12ce2375ae08755354c8ed5 Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Sat, 15 Jun 2019 14:01:10 +0200 Subject: [PATCH] How to cross compile for Windows --- README.md | 21 +++++++++++++++++++-- romdumps/romdumps_vfsdata.go | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4fc923a..6b3f7d0 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,8 @@ Only valid on SDL mode ### apple2console -The only dependency is having a working Go installation. +The only dependency is having a working Go installation on any platform. + Run: ``` $ go get github.com/ivanizag/apple2/apple2console @@ -136,9 +137,25 @@ $ go build github.com/ivanizag/apple2/apple2console ### apple2sdl -Besides having a working Go installation, install the SDL2 developer files. +Besides having a working Go installation, install the SDL2 developer files. Valid for any platform Run: ``` $ go get github.com/ivanizag/apple2/apple2sdl $ go build github.com/ivanizag/apple2/apple2sdl +``` + +### Cross compile apple2sdl.exe for Windows in Ubuntu + +Install the mingw cross compile tools and the [SDL2 Windows libs for mingw](https://www.libsdl.org/download-2.0.php). +``` +$ sudo apt install mingw-w64 +$ wget https://www.libsdl.org/release/SDL2-devel-2.0.9-mingw.tar.gz +$ tar -xzf SDL2-devel-2.0.9-mingw.tar.gz +$ sudo cp -r SDL2-2.0.9/x86_64-w64-mingw32/* /usr/x86_64-w64-mingw32 +``` +Compile: +``` +$ env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib -lSDL2 --verbose" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o apple2sdl.exe -x *.go +``` +To run the executable in Windows, copy the file `SDL2.dll` on the same folder. The latest `SDL2.dll` can be found in the [Runtime binary for Windows 64-bit](https://www.libsdl.org/download-2.0.php) diff --git a/romdumps/romdumps_vfsdata.go b/romdumps/romdumps_vfsdata.go index a606c6e..09c736a 100644 --- a/romdumps/romdumps_vfsdata.go +++ b/romdumps/romdumps_vfsdata.go @@ -134,7 +134,7 @@ func (fs vfsgen۰FS) Open(path string) (http.File, error) { } return &vfsgen۰CompressedFile{ vfsgen۰CompressedFileInfo: f, - gr: gr, + gr: gr, }, nil case *vfsgen۰DirInfo: return &vfsgen۰Dir{