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

Cannot cross-compile from Linux to Windows #155

Open
vonaka opened this issue Apr 9, 2023 · 3 comments
Open

Cannot cross-compile from Linux to Windows #155

vonaka opened this issue Apr 9, 2023 · 3 comments

Comments

@vonaka
Copy link

vonaka commented Apr 9, 2023

I'm trying to compile my application from Linux to Windows. I use go-gl jointly with go-sdl2 and to compile the program I follow these instructions. Additionally, I set CGO_CFLAGS to -DTAG_WINDOWS -D_WIN32 and CGO_LDFLAGS to -lopengl32 and I run go build with WGL tag:

env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" GOOS="windows" \
CGO_LDFLAGS="-lmingw32 -lSDL2 -lSDL2_image -lSDL2_ttf -lopengl32" \
CGO_CFLAGS="-D_REENTRANT -DTAG_WINDOWS -D_WIN32" \
go build -tags WGL -x test.go

Unfortunately, when I run the program on my Windows machine gl.Init fails to load glGetnTexImage. Following README, I call gl.Init after activating OpenGL context:

sdl.SetHint(sdl.HINT_RENDER_DRIVER, "opengl")
if glContext, err = window.GLCreateContext(); err != nil {
	//...
}
window.GLMakeCurrent(glContext)
if err = gl.Init(); err != nil {
	//...
}

On Windows I have opengl 4.6.

@vonaka vonaka changed the title Cannot cross-compile on Linux to Windows Cannot cross-compile from Linux to Windows Apr 9, 2023
@duysqubix
Copy link

Does this have an update by any chance?

Attempting to do the same thing, but:

package command-line-arguments
        imports github.com/duysqubix/gobc/internal/windows
        imports github.com/gopxl/pixel/v2/pixelgl
        imports github.com/go-gl/gl/v3.3-core/gl: build constraints exclude all Go files in /home/rpl-node/go/pkg/mod/github.com/go-gl/[email protected]/v3.3-core/gl

@vincent-alxr
Copy link

Does this have an update by any chance?

Attempting to do the same thing, but:

package command-line-arguments
        imports github.com/duysqubix/gobc/internal/windows
        imports github.com/gopxl/pixel/v2/pixelgl
        imports github.com/go-gl/gl/v3.3-core/gl: build constraints exclude all Go files in /home/rpl-node/go/pkg/mod/github.com/go-gl/[email protected]/v3.3-core/gl

I haved this issue, ensure mingw is correctly set in your var environnement

@bhperry
Copy link

bhperry commented Nov 15, 2024

Successfully got cross compilation to work following instructions here: https://stackoverflow.com/questions/41566495/golang-how-to-cross-compile-on-linux-for-windows

sudo apt-get install gcc-mingw-w64
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc go build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants