构建 fyne 应用时出现 glfw pkg-config 错误

咕噜代码:


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.

任何关于这个问题的解决方案或建议将不胜感激。P.S 我在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


希望有人可以帮助我,或者给我任何关于如何解决它的建议。


犯罪嫌疑人X
浏览 415回答 2
2回答

繁花如伊

某些 Linux 系统缺少已安装的图形库的编译头。值得庆幸的是,这仅用于开发 - 应用程序将在没有遇到这种情况的情况下运行。对于 Ubuntu 或 Debian,请尝试 .安装因平台而异,详情请见 https://developer.fyne.io/started/sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev

Qyouu

我在Linux Mint上有同样的问题,这很有帮助:&nbsp; &nbsp; locate pkgconfig/gl.pc&nbsp; &nbsp; /usr/lib/x86_64-linux-gnu/pkgconfig/gl.pc&nbsp; &nbsp; export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go