go-sdl2 icon indicating copy to clipboard operation
go-sdl2 copied to clipboard

static build in raspberry

Open fopina opened this issue 5 years ago • 5 comments

I was trying to avoid opening an issue but I saw that the linux arm flags were added with a commit message saying Android and RPi specifically so I'd like to know what I'm doing wrong...

# uname -a
Linux retropie 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l GNU/Linux
# cat /etc/*release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
# go version
go version go1.7.4 linux/arm
# make bubbles
go build -tags static -ldflags "-s -w" -o bubbles
# github.com/veandco/go-sdl2/sdl
/usr/bin/ld: cannot find -liconv
collect2: error: ld returned 1 exit status

After removing -liconv from *_cgo_static files I get

...
(.text+0x244): undefined reference to `libiconv_close'
...

As functions in libc (replacement of libiconv) are now called iconv_close only... How was that static library compiled? How did a libiconv get into that raspbian or was it done in arch (as that one seems to have a libiconv)?

After download libiconv tarball, compiling and installing it, I re-added -liconv to the flags and retried but

/tmp/go-build824492053/github.com/veandco/go-sdl2/sdl/_obj/_cgo_main.o:(.data.rel+0x0): undefined reference to `SDL_STANDARD_GRAVITY'
collect2: error: ld returned 1 exit status

fopina avatar Mar 14 '19 00:03 fopina

Actually, just tried with a docker image of arch linux (for RPi, nice exercise in case anyone interested) and even arch does not bring libiconv. After installing it though, we do get it as dependency as it is not statically linked in the binary so we end up with a static binary that won't run in neither of these RPi distros..

fopina avatar Mar 14 '19 14:03 fopina

All static libraries are cross-compiled on Gentoo (except for darwin). I have prepared different libraries for arm now, one for generic arm (GLES), one for RPi video driver and one for vivante, those will be available via tags, i.e. -tags rpi and default will be generic.

Not sure how what currently is in the repo is built, I removed recently all old toolchains I had, but this change, I want to push should fix the issue you have. Will push the change when I find the time, there is not too much work left but I am very busy currently.

gen2brain avatar Mar 14 '19 20:03 gen2brain

Awesome news! If you care to share just the rpi lib adhoc somehow (if it’s already built), I’d give it a go in my setup :)

fopina avatar Mar 14 '19 20:03 fopina

You can try with these, just rename them appropriately and I am not sure if any change is needed in SDL_config.h.

http://185.177.59.7/tmp/libs-arm.tar.gz http://185.177.59.7/tmp/libs-rpi.tar.gz

gen2brain avatar Mar 14 '19 20:03 gen2brain

Thanks for the quick share! There's something strange with the headers indeed as it keeps complaining about SDL_GRAVITY constant (which exists in the repo headers but not in libsdl installed in my raspberry). Replacing it yields other constants missing. And as I also need the gfx, I'll just wait for your release then, in the meantime I'll use dynamic linking :)

Thanks!

fopina avatar Mar 15 '19 01:03 fopina