veandco / go-sdl2

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

static build using `go mod` #393

Closed fopina closed 5 years ago

fopina commented 5 years ago

go mod does not keep . directories so we cannot compile statically if using it.

maybe they should be moved to another repository and instructions provided on how to use them in non-default location? That'd be awesome :)

veeableful commented 5 years ago

Hi @fopina, could you elaborate on what you mean? I was able to build the program using go mod method if I run go get -v github.com/veandco/go-sdl2/sdl@master before compilation. I used the command: CGO_ENABLED=1 CC=gcc GOOS=linux GOARCH=amd64 go build -tags static -ldflags "-s -w" to build it.

fopina commented 5 years ago

You’re right, this question doesn’t make much sense. It just seems wrong to get the dep into GOPATH/pkg with go mod and then go get it tO GOPATH/src because of the libs. If they were a separate repo, I could just clone without duplicating stuff and set the appropriate LDFLAGS and CFLAGS. But it’s not an issue, so closing :)

veeableful commented 5 years ago

It just seems wrong to get the dep into GOPATH/pkg with go mod and then go get it tO GOPATH/src because of the libs.

Perhaps you could tell me what you are trying to accomplish. If this makes the package better, I need to hear it!

fopina commented 5 years ago

props for the spirit @veeableful but it is likely this is just me being wrong. I'm new to go (but go is also still quite new/imature from the little I've seen) and trying to get the grip on proper code structure and design, so I decided to use go mod in everything I do.

But in this case, as there's the bonus of getting the static libs (which is awesome, not only we do not need to install libsdl* packages in the build machine but we also get a static version of the binary to run in alikes), I need to go get it as well, because the version that is fetch does not have the libs. So it feels kind of duplicate to get go-sdl2 into pkg (go mod) and src (go get).

I don't really think libs should be in the main repo as forking and contributing makes those binaries go round and round but that's personal preferences...

The linux_arm static lib does not compile in raspberry though, it seems it is statically linked to iconv and libiconv is no longer used as iconv is part of libc, but that's out of topic here :)

I'll close this to avoid cluttering with invalid issues, sorry!