When building Hello World app on Ubuntu 20.04 I got this error message:
# github.com/go-gl/glfw/v3.3/glfw
/usr/bin/ld: cannot find -lXxf86vm
collect2: error: ld returned 1 exit status
I managed to work-around this issue by doing this:
sudo apt install libxxf86vm-dev
Steps to reproduce the behaviour:
package main
import (
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
)
func main() {
a := app.New()
w := a.NewWindow("hello")
w.SetContent(widget.NewLabel("Hello World!"))
w.ShowAndRun()
}
That should have been installed by the apt-get install command that is listed at https://developer.fyne.io/started/.
This is just a development dependency and is not required by the users of your app.
Thank you for your response.
I used this command line to install fyne:
go get fyne.io/fyne
Is that not supposed to be sufficient?
The command you post prepares the library, however if you don't have developer tools installed it can fail to compile.
On most operating systems that should work out of the box, but Linux is a little complicated and needs the developer libraries installed as listed in the documentation.
This is due to the way that Linux development is split into many different packages, on some distributions (such as Ubuntu) the presence of a graphics driver does not ensure the development libraries to go with it. From our doc on the "Linux" tab at the page I posted above:
You will need to install Go, gcc and the graphics library header files using your package manager
Thanks again for pointing me in right direction.
Could you elaborate on this one:
"This is just a development dependency and is not required by the users of your app."
If I distribute the binary "hello" would others not need to install development dependencies? If the answer is yes, why did I have to install them when running hello?
If I distribute the binary "hello" would others not need to install development dependencies?
Yes this is exactly correct.
The reason you need development dependencies to run the hello world is because the "go get" command is building it from source. Distributed apps will typically be compiled and packaged, meaning no need for go tools or dependencies.
Ok, is there a go command to make the distributable version of hello binary then?
go build will build a binary file you can share.
If you want to package a full desktop app with metadata etc then fyne package is your friend, see https://developer.fyne.io/started/distribution
Just to clarify. The development dependencies are statically linked into the binary. That鈥檚 rather technical, but the consequence is basically that the compiled binary includes the needed dependencies. That is why they are only needed when you are compiling and not when running it 馃檪
@Jacalz thank you for explaining this even clearer. This will help people googling about this behaviour in the future 馃尡
To summarize this for future reference:
FYI - the resulting application/executable was 17 mb on my machine, and it was possible to run it even after sudo apt-get remove libgl1-mesa-dev xorg-dev, as expected. I also found the "upx-ucl" utility for Ubuntu to compress the binary, so it is now down to 9 mb. Nice!