戈朗代码:
package main
import (
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
)
func main() {
application := app.New()
window = application.NewWindow("Hello rohan")
window.SetContent(widget.NewLabel("Hello again"))
window.ShowAndRun()
}
执行此代码时,出现以下错误。
# pkg-config --cflags -- gl gl
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gl' found
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gl' found
pkg-config: exit status 1
# fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw
In file included from ./glfw/src/internal.h:188,
from ./glfw/src/context.c:30,
from ../../../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw/c_glfw.go:4:
./glfw/src/x11_platform.h:36:10: fatal error: X11/Xcursor/Xcursor.h: No such file or directory
36 | #include <X11/Xcursor/Xcursor.h>
| ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
对此问题的任何解决方案或建议将不胜感激。PS 我在 Windows 上使用 Go 版本 1.13.8 和 ubuntu 20.04 WSL。
运行sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev
命令后,我现在收到此错误:
2020/12/21 12:12:19 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized
goroutine 1 [running, locked to thread]:
fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw.acceptError(0x0, 0x0, 0x0, 0x4332bd, 0x991100)
/home/rohan/go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw/error.go:174 +0x216
fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw.panicError(...)
/home/rohan/go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw/error.go:185
fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw.CreateStandardCursor(0x36001, 0x1)
/home/rohan/go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw/input.go:530 +0x4e
fyne.io/fyne/internal/driver/glfw.initCursors()
/home/rohan/go/src/fyne.io/fyne/internal/driver/glfw/window.go:35 +0x3c
fyne.io/fyne/internal/driver/glfw.(*gLDriver).initGLFW.func1()
/home/rohan/go/src/fyne.io/fyne/internal/driver/glfw/loop.go:76 +0x6b
sync.(*Once).doSlow(0x10de160, 0xc000068dc8)
/usr/lib/go-1.13/src/sync/once.go:66 +0xe3
sync.(*Once).Do(...)
/usr/lib/go-1.13/src/sync/once.go:57
fyne.io/fyne/internal/driver/glfw.(*gLDriver).initGLFW(0xc0000c00f0)
/home/rohan/go/src/fyne.io/fyne/internal/driver/glfw/loop.go:69 +0x65
fyne.io/fyne/internal/driver/glfw.(*gLDriver).createWindow.func1()
/home/rohan/go/src/fyne.io/fyne/internal/driver/glfw/window.go:1175 +0x56
fyne.io/fyne/internal/driver/glfw.runOnMain(0xc0000a5440)
/home/rohan/go/src/fyne.io/fyne/internal/driver/glfw/loop.go:51 +0xab
fyne.io/fyne/internal/driver/glfw.(*gLDriver).createWindow(0xc0000c00f0, 0x9b7b98, 0xb, 0xc000146001, 0xc000068f08, 0x85c288)
/home/rohan/go/src/fyne.io/fyne/internal/driver/glfw/window.go:1174 +0xd4
fyne.io/fyne/internal/driver/glfw.(*gLDriver).CreateWindow(0xc0000c00f0, 0x9b7b98, 0xb, 0xc000146000, 0xc0000c00f0)
/home/rohan/go/src/fyne.io/fyne/internal/driver/glfw/window.go:1166 +0x44
fyne.io/fyne/app.(*fyneApp).NewWindow(0xc000146000, 0x9b7b98, 0xb, 0xc000146000, 0x0)
/home/rohan/go/src/fyne.io/fyne/app/app.go:52 +0x47
main.main()
/home/rohan/Code/Go/practice/main.go:10 +0x56
exit status 2
希望有人可以帮助我,或者就如何解决它给我任何建议。