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

Can't find any SDL_Sensors code (linux) #371

Closed dpeckham closed 5 years ago

dpeckham commented 5 years ago

This simple test program won't compile... other go "hello world" apps are working, and C SDL2 examples are working. This won't.

main.go:

func main() { if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil { panic(err) } defer sdl.Quit() }

$ go build main.go

command-line-arguments

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_NumSensors': /tmp/go-build/cgo-gcc-prolog:43: undefined reference toSDL_NumSensors' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorFromInstanceID': /tmp/go-build/cgo-gcc-prolog:62: undefined reference toSDL_SensorFromInstanceID' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetData': /tmp/go-build/cgo-gcc-prolog:84: undefined reference toSDL_SensorGetData' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetDeviceInstanceID': /tmp/go-build/cgo-gcc-prolog:104: undefined reference toSDL_SensorGetDeviceInstanceID' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetDeviceName': /tmp/go-build/cgo-gcc-prolog:123: undefined reference toSDL_SensorGetDeviceName' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetDeviceNonPortableType': /tmp/go-build/cgo-gcc-prolog:143: undefined reference toSDL_SensorGetDeviceNonPortableType' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetDeviceType': /tmp/go-build/cgo-gcc-prolog:163: undefined reference toSDL_SensorGetDeviceType' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetInstanceID': /tmp/go-build/cgo-gcc-prolog:182: undefined reference toSDL_SensorGetInstanceID' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetName': /tmp/go-build/cgo-gcc-prolog:200: undefined reference toSDL_SensorGetName' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetNonPortableType': /tmp/go-build/cgo-gcc-prolog:219: undefined reference toSDL_SensorGetNonPortableType' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorGetType': /tmp/go-build/cgo-gcc-prolog:238: undefined reference toSDL_SensorGetType' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorOpen': /tmp/go-build/cgo-gcc-prolog:257: undefined reference toSDL_SensorOpen' /usr/bin/ld: /tmp/go-link-683652254/000028.o: in function _cgo_9ed60ab90e3e_Cfunc_SDL_SensorUpdate': /tmp/go-build/cgo-gcc-prolog:272: undefined reference toSDL_SensorUpdate' collect2: error: ld returned 1 exit status

$ apt list | grep sdl | grep installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libsdl2-2.0-0/cosmic,now 2.0.8+dfsg1-4ubuntu1 amd64 [installed] libsdl2-dev/cosmic,now 2.0.8+dfsg1-4ubuntu1 amd64 [installed] libsdl2-gfx-1.0-0/cosmic,now 1.0.4+dfsg-1 amd64 [installed,automatic] libsdl2-gfx-dev/cosmic,now 1.0.4+dfsg-1 amd64 [installed] libsdl2-image-2.0-0/cosmic,now 2.0.3+dfsg1-1 amd64 [installed,automatic] libsdl2-image-dev/cosmic,now 2.0.3+dfsg1-1 amd64 [installed] libsdl2-mixer-2.0-0/cosmic,now 2.0.2+dfsg1-2 amd64 [installed] libsdl2-mixer-dev/cosmic,now 2.0.2+dfsg1-2 amd64 [installed] libsdl2-net-2.0-0/cosmic,now 2.0.1+dfsg1-3 amd64 [installed] libsdl2-net-dev/cosmic,now 2.0.1+dfsg1-3 amd64 [installed] libsdl2-ttf-2.0-0/cosmic,now 2.0.14+dfsg1-2 amd64 [installed] libsdl2-ttf-dev/cosmic,now 2.0.14+dfsg1-2 amd64 [installed]

Ubuntu Linux uname -a Linux dave-linux 4.18.0-13-generic #14-Ubuntu SMP Wed Dec 5 09:04:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

veeableful commented 5 years ago

Wow that is strange. Could it be somehow using newer SDL2 headers but linking to outdated SDL2 libraries? Did you install a custom version of SDL2?

I installed on my own Ubuntu 18.10 and it seems to work.

dpeckham commented 5 years ago

I've got it working on another distro (Arch) for now. Closing...