英文:
installing fyne package, it fails with `cannot find -lXxf86vm`
问题
我正在为您翻译以下内容:
我尝试运行在https://github.com/fyne-io/fyne中提供的演示代码。
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Hello")
hello := widget.NewLabel("Hello Fyne!")
w.SetContent(container.NewVBox(
hello,
widget.NewButton("Hi!", func() {
hello.SetText("Welcome :)")
}),
))
w.ShowAndRun()
}
但是它显示以下错误:
go: 下载 github.com/stretchr/testify v1.6.1
go: 下载 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: 下载 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
github.com/go-gl/glfw/v3.3/glfw
/usr/bin/ld: 无法找到 -lXxf86vm
collect2: 错误:ld 返回了 1 个退出状态
我正在运行 go 版本 go1.16.7 linux/amd64。
英文:
i was trying to run the demo code given in https://github.com/fyne-io/fyne
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Hello")
hello := widget.NewLabel("Hello Fyne!")
w.SetContent(container.NewVBox(
hello,
widget.NewButton("Hi!", func() {
hello.SetText("Welcome :)")
}),
))
w.ShowAndRun()
}
but it showing this error
go: downloading github.com/stretchr/testify v1.6.1
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
github.com/go-gl/glfw/v3.3/glfw
/usr/bin/ld: cannot find -lXxf86vm
collect2: error: ld returned 1 exit status
i am running go version go1.16.7 linux/amd64
答案1
得分: 1
如果你在Linux上进行编译,可能需要一些额外的库头文件-请查看https://developer.fyne.io/started/上的说明。
根据你的发行版,库的名称可能会有所不同,但可能会被命名为libXxf86vm-devel
。
英文:
If you're compiling on Linux you may need a few extra library headers - check out the instructions at https://developer.fyne.io/started/.
Depending on your distribution the library name will vary, but it might be named like libXxf86vm-devel
.
答案2
得分: 1
我在这里为Ubuntu 20.04和golang go1.16.5提供一个解决方案。
我已经安装了gcc,但我发现我还需要以下系统依赖:
sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev xorg-dev
我的Makefile用于构建:
build:
go mod download
CGO_ENABLED=1 go build -ldflags "-s -w" -o $(BINARY)
简单的main.go文件:
import (
"fyne.io/fyne/v2/app"
)
func main() {
a := app.New()
w := a.NewWindow("Server Mon")
w.ShowAndRun()
}
当我构建时,会出现一系列缺少的go依赖项的堆栈跟踪,例如:
<pre>../../../gopkg/pkg/mod/fyne.io/fyne/v2@v2.0.4/storage/repository/parse.go:8:2: missing go.sum entry for module providing package github.com/fredbi/uri (imported by fyne.io/fyne/v2/
</pre>
通过以下步骤解决所有这些问题:
go get fyne.io/fyne/v2/app@v2.0.4
go get fyne.io/fyne/v2/storage/repository@v2.0.4
go get fyne.io/fyne/v2/internal/painter/gl@v2.0.4
go get fyne.io/fyne/v2/internal/driver/glfw@v2.0.4
通过上述步骤,一切都可以构建和运行。
英文:
I am adding a solution here for Ubuntu 20:04 with golang go1.16.5
I had gcc, I found I needed the following system dependencies
sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev xorg-dev
my makefile for build
build:
go mod download
CGO_ENABLED=1 go build -ldflags "-s -w" -o $(BINARY)
simple main.go
import (
"fyne.io/fyne/v2/app"
)
func main() {
a := app.New()
w := a.NewWindow("Server Mon")
w.ShowAndRun()
}
when I build get a number of missing go dependencies stacktrace like
<pre>../../../gopkg/pkg/mod/fyne.io/fyne/v2@v2.0.4/storage/repository/parse.go:8:2: missing go.sum entry for module providing package github.com/fredbi/uri (imported by fyne.io/fyne/v2/
</pre>
theses all resolved with
go get fyne.io/fyne/v2/app@v2.0.4
go get fyne.io/fyne/v2/storage/repository@v2.0.4
go get fyne.io/fyne/v2/internal/painter/gl@v2.0.4
go get fyne.io/fyne/v2/internal/driver/glfw@v2.0.4
with above steps everything builds and runs
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论