Skip to content

Cannot cross-compile from Linux to Windows #155

@vonaka

Description

@vonaka

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions