Open MrWaggel opened 1 year ago
Hi :) I might be a problem on our side. Harfang 3.2.4 is supposed to build on Lua5.4. We have an ongoing release of the engine, and it includes the Go bindings. I shall be able to update you before the end of the week. Thanks for your interest in Harfang :)
Okay, I managed to get way further with the 3.2.5 release.
First I needed to install the libglfw-dev package.
Added some flags in the bind.go file
1) Prepend the CGFLAGS with -I/usr/local/include (location of the Lua 5.4 header files) 2) Prepend the linux LDFLAGS with -L/usr/local/lib/liblua.a for linking 3) Append the linux LDFLAGS with -llua -lglfw
thus the result;
// #include "wrapper.h"
// #cgo CFLAGS: -I/usr/local/include -I . -Wall -Wno-unused-variable -Wno-unused-function -O3
// #cgo CXXFLAGS: -std=c++14 -O3
// #cgo linux pkg-config: gtk+-3.0
// #cgo linux LDFLAGS: -L/usr/local/lib/liblua.a -L${SRCDIR}/linux -lhg_go -lharfang -lm -lstdc++ -Wl,--no-as-needed -ldl -lGL -lXrandr -lXext -lX11 -lglib-2.0 -llua -lglfw
// #cgo windows LDFLAGS: -L${SRCDIR}/windows -lhg_go -lharfang -lGdi32 -lDbghelp -lshell32 -loleaut32 -luuid -lcomdlg32 -lOle32 -lWinmm -lstdc++
// #cgo LDFLAGS: -lstdc++ -L. -lharfang
Now the draw_lines.go example compiles, runs for one frame (i can see the window for a very brief moment), but results in a fatal error.
/tmp/GoLand/___2go_build_draw_lines_go
(1671024492:203:506:389) Render pipeline memory footprint:
(1671024492:204:084:199)
(1671024492:204:102:555) Structure | sizeof (bytes)
(1671024492:204:112:565) ------------------+---------------
(1671024492:204:123:206) PipelineInfo | 56
(1671024492:204:136:787) PipelineProgram | 256
(1671024492:204:150:233) Texture | 16
(1671024492:204:163:251) UniformSetValue | 40
(1671024492:204:176:071) UniformSetTexture | 32
(1671024492:204:189:359) ProgramHandle | 4
(1671024492:204:202:680) Material | 136
(1671024492:204:627:324) DisplayList | 32
(1671024492:204:649:274) ModelDisplayList | 16
(1671024492:204:662:648) Model | 96
(1671024492:204:675:649) ModelInfo | 84
(1671024492:204:688:754) ViewState | 208
(1671024492:204:701:682) Indices | 24
(1671024492:204:714:772) Vertices | 112
(1671024492:204:727:067)
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x3930 pc=0x7fc87acbe4c9]
runtime stack:
runtime.throw({0xcea89f, 0x0})
/usr/local/go/src/runtime/panic.go:1198 +0x71
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:719 +0x396
goroutine 1 [syscall]:
runtime.cgocall(0x606990, 0xc000049ef0)
/usr/local/go/src/runtime/cgocall.go:156 +0x5c fp=0xc000049ec8 sp=0xc000049e90 pc=0x58e9fc
github.com/harfang3d/harfang-go/v3._Cfunc_HarfangFrame()
_cgo_gotypes.go:14240 +0x48 fp=0xc000049ef0 sp=0xc000049ec8 pc=0x5efbe8
github.com/harfang3d/harfang-go/v3.Frame(...)
/home/gilles/go/pkg/mod/github.com/harfang3d/harfang-go/v3@v3.2.5/bind.go:21388
main.main()
/home/gilles/go/src/wowkill/tutorials/draw_lines.go:47 +0x125 fp=0xc000049f80 sp=0xc000049ef0 pc=0x5fa8e5
runtime.main()
/usr/local/go/src/runtime/proc.go:255 +0x227 fp=0xc000049fe0 sp=0xc000049f80 pc=0x5bcd87
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000049fe8 sp=0xc000049fe0 pc=0x5e3681
Process finished with the exit code 2
The first issue (undefined references to Lua) is caused by a regression in the harfang go module build script.
The second one was a little bit tricky to track down.
Long story short, OpenGL functions were called from another thread without proper OpenGL context switching.
To fix this, call runtime.LockOSThread()
at the beginning of the main
function.
This will be fixed in the next release.
I'm interested fiddling around with this package, but upon building I keep getting Lua binding errors.
I have liblua5.3-dev installed on my machine, and tried passing flags to gc with no avail.
-gcflags '-I/usr/include/lua5.3 -L/usr/lib/x86_64-linux-gnu/liblua5.3.a'
Any steps that I am missing?
Greetings and thanks in advance.