tbogdala / openvr-go

golang wrapper of Valve's OpenVR library
BSD 2-Clause "Simplified" License
30 stars 9 forks source link

Fixed compile errors #2

Closed gamerscomplete closed 7 years ago

gamerscomplete commented 7 years ago

I pulled down openvr_capi.h from https://raw.githubusercontent.com/ValveSoftware/openvr/master/headers/openvr_capi.h

This got rid of all the compile errors I had for https://github.com/tbogdala/openvr-go/issues/1

This left just a few compile errors in the go code that was using int's instead of booleans. I updated those to be boolean and now everything compiles.

I am still working on on fixing the linking error on runtime tho.

./connectiontest: error while loading shared libraries: libopenvr_api.so: cannot open shared object file: No such file or directory

tbogdala commented 7 years ago

You need to copy the appropriate library file to the directory manually. The #cgo directives take care of things while compiling but at runtime the correct .so file cannot be located unless it's in a well known spot for the system.

I'll review this patch soon. It seems fine. I'm surprised I missed constants still as I've swept through the header a few times already...

gamerscomplete commented 7 years ago

I got the linking issue sorted by setting the linker path export LD_LIBRARY_PATH=../../vendor/openvr/lib/linux64/

I get a segmentation fault when using the libopenvr_api.so that is vendored.

[signal SIGSEGV: segmentation violation code=0x1 addr=0x3d4 pc=0x7f9558184f91]

runtime stack:
runtime.throw(0x5d7090, 0x2a)
        /usr/local/go/src/runtime/panic.go:596 +0x95
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:274 +0x2db

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x544600, 0xc420055b30, 0xc420055b38)
        /usr/local/go/src/runtime/cgocall.go:131 +0xe2 fp=0xc420055af0 sp=0xc420055ab0
github.com/tbogdala/openvr-go._Cfunc_initInternal(0x1, 0xc400000000)
        github.com/tbogdala/openvr-go/_obj/_cgo_gotypes.go:494 +0x4d fp=0xc420055b30 sp=0xc420055af0
github.com/tbogdala/openvr-go.Init(0xc420014720, 0xc420014750, 0xc420055c80)
        /home/chris/checkout/src/github.com/tbogdala/openvr-go/openvr.go:126 +0x2d fp=0xc420055ba0 sp=0xc420055b30
main.main()
        /home/chris/checkout/src/github.com/tbogdala/openvr-go/examples/basiccube/main.go:74 +0x149 fp=0xc420055f88 sp=0xc420055ba0
runtime.main()
        /usr/local/go/src/runtime/proc.go:185 +0x20a fp=0xc420055fe0 sp=0xc420055f88
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420055fe8 sp=0xc420055fe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1

Using the version that comes in steamVR (I assume a newer version) I get a cleaner error, but it panics none the less. export LD_LIBRARY_PATH=~/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/ ./basiccube

panic: vr.Init() returned an error: vrclient Shared Lib Not Found (102)

goroutine 1 [running, locked to thread]:
main.main()
        /home/chris/checkout/src/github.com/tbogdala/openvr-go/examples/basiccube/main.go:76 +0x214

I will hack on this a bit more tonight to see if I can make some more progress. Not sure where those panics are surfacing from right now

tbogdala commented 7 years ago

Updating LD_LIBRARY_PATH will do the trick too, correct. The vendored binaries were from the 1.0.5 release on the openvr git repo. Using the newer one should technically act similar because the code will still be bound to requesting specific versions of the interfaces. Based on this post it seems like the error is the vrclient library from Steam not being loaded. It's been my experience that I can't start VR mode from the steam client, which would normally take care of this.

A few months back I got some of this stuff working in linux and made a reddit post on it. Check out the article I linked there. I avoided sourcing the script for a long while, but once I just executed that script things started to work better.

I work weird hours (tonight is my fifth 12 hour shift in a row) and my next day off is Wednesday, so I'll be able to get to this stuff better then.

tbogdala commented 7 years ago

It does compile fine in Linux, but when I compile on Win10, I get the following errors:

$ go build
# github.com/tbogdala/openvr-go
..\..\ivrcompositor.go:85: non-bool comp.renderPoseArray[i].bPoseIsValid (type C.bool) used as if condition
..\..\ivrcompositor.go:120: non-bool cTDP.bPoseIsValid (type C.bool) used as if condition
..\..\ivrcompositor.go:124: non-bool cTDP.bDeviceIsConnected (type C.bool) used as if condition
..\..\ivrsystem.go:150: invalid operation: ! C.bool
..\..\ivrsystem.go:165: non-bool (func literal)(sys.ptr, C.TrackedDeviceIndex_t(deviceIndex)) (type C.bool) used as if c                                 ondition
..\..\ivrsystem.go:185: non-bool (func literal)(sys.ptr) (type C.bool) used as if condition
..\..\ivrsystem.go:224: non-bool result (type C.bool) used as if condition
..\..\ivrsystem.go:259: non-bool result (type C.bool) used as if condition

Since I'm not convinced I can get openvr to run correctly on Linux as it is, I don't want to break the only platform this library is currently useful on.