douhui9192 2018-11-21 21:52
浏览 1428

Golang OpenGL错误PlatformError:X11:DISPLAY环境变量缺少紧急信息:NotInitialized:GLFW库未初始化

I just cannot seem to get opengl with golang to work. I wanted to try out golang but it has been such a pain to even set up, and now I can't get something I copy pasted off of this website. Here is the code I am using: (from the website). I did these two commands before running it (using wsl on windows):

go get github.com/go-gl/gl/v4.1-core/gl
go get github.com/go-gl/glfw/v3.2/glfw

And this is the full error I am getting:

2018/11/21 13:43:33 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.2/glfw.acceptError(0x0, 0x0, 0x0, 0x1, 0xc000099ee0)
        /home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:173 +0x1d1
github.com/go-gl/glfw/v3.2/glfw.panicError()
        /home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/error.go:184 +0x32
github.com/go-gl/glfw/v3.2/glfw.WindowHint(0x20003, 0x0)
        /home/oriont/dev/src/github.com/go-gl/glfw/v3.2/glfw/window.go:235 +0x38
main.initGlfw(0x4ded35)
        /home/oriont/dev/super g/main.go:71 +0x54
main.main()
        /home/oriont/dev/super g/main.go:45 +0x2b
exit status 2

And if you are curious, my go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oriont/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oriont/dev"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.11"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.11/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build854283259=/tmp/go-build -gno-record-gcc-switches"

Any help would be appreciated, thanks!

EDIT:

Now I am getting a new error, after reinstalling go and removing a failed attempt at sdl2 (from apt-get remove).

(OLD) This is the new error:

# _/home/oriont/dev/super_g
/usr/lib/go-1.11/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lXrandr
collect2: error: ld returned 1 exit status

I have all of the same code still. Also, I did try to run 'go build' but it just threw the exact same error as 'go run main.go'.

EDIT 2:

I reinstalled go 1.11.2 and installed the libglfw3 and libglfw3-dev packages on sudo apt-get install. Now, I have the same old error.

  • 写回答

1条回答 默认 最新

  • 普通网友 2018-11-22 00:33
    关注

    My solution is to literally install GoLang and TDM-GCC on windows, and do it through the command prompt INSTEAD OF BASH.

    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面