Search code examples
gofyne

installing fyne package, it fails with `cannot find -lXxf86vm`


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


Solution

  • 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

    ../../../gopkg/pkg/mod/fyne.io/fyne/[email protected]/storage/repository/parse.go:8:2: missing go.sum entry for module providing package github.com/fredbi/uri (imported by fyne.io/fyne/v2/
    

    theses all resolved with

    go get fyne.io/fyne/v2/[email protected]
    go get fyne.io/fyne/v2/storage/[email protected]
    go get fyne.io/fyne/v2/internal/painter/[email protected]
    go get fyne.io/fyne/v2/internal/driver/[email protected]
    

    with above steps everything builds and runs