fyne-cross: fyne-cross option -ldflags does not work properly like it does in go build

Describe the bug:

Unlike go build fyne-cross option ldflags does nothing when I try to set global var with ldflags "-X 'main.ver=1.0.0'"

To Reproduce:

For the code beneath - steps to reproduce the behavior:

  1. Run the command fyne-cross linux -ldflags "-X 'main.version=0.0.1'"

  2. Run executable was built

  3. See no version is displayed image

  4. Run the same code with the command go run -ldflags "-X 'main.version=0.0.1'" .

  5. See version is displayed image

Example code:


package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/widget"
)

var version string

func main() {
	a := app.New()
	w := a.NewWindow("Hello World")
	w.Resize(fyne.NewSize(200, 100))

	w.SetContent(widget.NewLabel("Version: " + version))
	w.ShowAndRun()
}

Device and debug info (please complete the following information):

Device info
  • OS: Linux
  • Version: Ubuntu 22.04.2 LTS
  • Go version: go1.20.3 linux/arm64
  • fyne-cross version: v1.4.0
  • Fyne version: not installed

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Yes, that’s why I did open PR #193 . The things that should currently work is: fyne-cross linux -ldflags=-X=main.version=0.0.1 -no-strip-debug