Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help requested] Cross-compile from WSL to Windows #336

Open
adam000 opened this issue May 13, 2018 · 6 comments
Open

[Help requested] Cross-compile from WSL to Windows #336

adam000 opened this issue May 13, 2018 · 6 comments
Labels
support This issue was posted by user to ask for help

Comments

@adam000
Copy link

adam000 commented May 13, 2018

tl;dr: I'm trying to cross-compile an application using go-sdl2 and the Windows Subsystem for Linux (or WSL) to build a Windows binary on a Windows machine, without Windows hassles. There is a runtime error that I am trying to figure out:

Failed to load PNG: Failed loading libpng16-16.dll: The specified procedure could not be found.

The repository with a fully-reproducible build is here: https://github.com/adam000/go-sdl2-wsl-build-windows


The details:

Go version: go version go1.10.2 linux/amd64 (cross-compile to Windows)
Using 64 bit mingw installed via apt-get

Operating system: Windows 10 version 1709 (OS Build 16299.431)

After seeing that v0.3 was launched and reading the README again, I noticed that there were some instructions for cross-compiling from Arch Linux to Windows, so I thought I'd give it a shot using the Windows Subsystem for Linux (which is built from Ubuntu Linux).

I installed Go with my homebuilt script: https://github.com/adam000/goutils/blob/master/scripts/make-go-latest.bash

Then, I installed some things via apt-get:

sudo apt-get install mingw-w64 unzip

So I tweaked the instructions from the README of go-sdl2 a bit and made a Go program and a bash script to make things easier on myself. The Go program handles the procurement and placement of all the necessary SDL libraries and development packages. The bash script wraps that and makes a cross-platform build, using the arguments described in the README of go-sdl2. It then copies it to the current user's Desktop on Windows.

I've created the repository using the texture_png example from the go-sdl2-examples repository, to eliminate any issues that may be specific to my private game's repository. I'm hoping that this repository will help in figuring out what my problem is. I find it very strange that it lists the error of being unable to use libpng16-16.dll when it shows up in my build:

image

Anyways, I know this is a lot but I'm hoping with these instructions, we can make it really easy to build go-sdl2 applications from WSL for Windows. I am very willing to contribute these scripts to the veandco team once we figure these issues out :)

@veeableful
Copy link
Contributor

Hi @adam000, I will give this a shot when I have a chance.

@veeableful veeableful added the support This issue was posted by user to ask for help label May 15, 2018
@stuartdd
Copy link

Hi @adam000, I almost got this working on the Ubuntu WSL but failed at the last stage when cross compiling with the old SDL2/SDL2.h trap.

I have been trying to put a Windows 10 build together for some time.

I would love to see the results (no rush!)

Stuart

@veeableful
Copy link
Contributor

I've installed WSL and tried the script yesterday and I've also come across the same issue being libpng16-16.dll not found. I'll try and see if I can't solve the problem.

@adam000
Copy link
Author

adam000 commented May 18, 2018

@veeableful @stuartdd Good and bad news! It seems that the project succeeds if I change the SDL_image version to 2.0.1 instead of the most current version, 2.0.3. (in my test project, this can be done by changing line 38 of build/grab-win64-resources-on-wsl.go)

The other bad news is that I won't have a Windows development machine for a week or so. I'm willing to ask around on the SDL forums when I get back.

@adam000
Copy link
Author

adam000 commented Jul 16, 2018

An update: I was hoping to have better news and sooner, but I haven't heard anything back on the bug I submitted regarding this problem.

It appears to have been caused by SDL2_image updating its version of libpng. A workaround is providing the libpng dll from 2.0.1 with all of the other DLLs packaged with 2.0.3.

@Suceru
Copy link

Suceru commented Jan 26, 2020

Hi, for SDL2_image to work properly, I copy the zlib1.dll file to current path of cmd.
Or copy all img.dll file to that.

eg:
Copy the zlib1.dll to %GOPATH%\src\github.com\veandco\go-sdl2\.go-sdl2-examples\examples\texture_png\

then

go run %GOPATH%\src\github.com\veandco\go-sdl2.go-sdl2-examples\examples\texture_png\texture_png.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support This issue was posted by user to ask for help
Projects
None yet
Development

No branches or pull requests

4 participants