veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.17k stars 219 forks source link

Invalid type error when building for i386 #543

Closed bytecounter closed 1 year ago

bytecounter commented 1 year ago

When trying to build for i368 architecture, I got this error: /go/pkg/mod/github.com/veandco/go-sdl2@v0.4.26/sdl/guid.go:38:33: cannot use _cap (variable of type _Ctype_ulong) as type _Ctype_uint in argument to (_Cfunc_SDL_malloc)

Environment: Docker 20.10.12 on Ubuntu 22.04 LTS

go.mod

module sdl-2

go 1.18

require github.com/veandco/go-sdl2 v0.4.26

Go-Source:

package main

import (
    "github.com/veandco/go-sdl2/sdl"
)

func main() {
    sdl.Init(sdl.INIT_EVERYTHING)
}

My Dockerfile:

FROM golang:1.19

RUN \
    dpkg --add-architecture i386 \
    && apt update \
    && apt upgrade -y \
    && apt install -y \
        libsdl2{,-image,-mixer,-ttf,-gfx}-dev \
        gcc-multilib \
        libsdl2{,-image,-mixer,-ttf,-gfx}-dev:i386

Build command: docker run --rm -it -v "$PWD":/usr/src/myapp -v "$HOME/go":/go -w /usr/src/myapp -e CGO_ENABLED=1 -e GOOS=linux -e GOARCH=386 -e CC=gcc golang-sdl2 go build -v -x -o build/test-sdl2_32 *.go

Build command for 64 bit linux works fine: docker run --rm -it -v "$PWD":/usr/src/myapp -v "$HOME/go":/go -w /usr/src/myapp -e CGO_ENABLED=1 -e GOOS=linux -e GOARCH=amd64 -e CC=gcc golang-sdl2 go build -v -x -o build/test-sdl2_64 *.go

veeableful commented 1 year ago

Hi @bytecounter, thanks for reporting this issue! I have backported a fix from the main branch into v0.4.27 after testing with a similar container setup as the one provided. Could you try it out and let me know if it fixes the problem for you?

bytecounter commented 1 year ago

@veeableful , thank you for the very fast bugfixing! I can confirm, that is fixed with 0.4.37. My build was successful.