go-autostart icon indicating copy to clipboard operation
go-autostart copied to clipboard

Problem with cross compilation for Windows

Open es1o opened this issue 4 years ago • 3 comments

Hello. I'm trying to compile code for windows from MacOS and Linux and I've got an error:

app.Enable undefined (type *autostart.App has no field or method Enable)

My code:

     if runtime.GOOS == "windows" {
		exe, _ := os.Executable()
		app := &autostart.App{
			Name:        "test",
			DisplayName: "test",
			Exec:        []string{exe},
		}
		app.Enable()
	}

es1o avatar Nov 18 '21 16:11 es1o

Any News on that? I'm getting the same error

obuchmann avatar Jan 20 '23 14:01 obuchmann

Make sure to have CGO_ENABLED=1

kamushadenes avatar Apr 01 '23 12:04 kamushadenes

I'm on mac and I needed to do the following in order to compile the code for Windows

$> brew install mingw-w64
$> GOARCH=amd64 GOOS=windows CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build cmd/main.go

And voila!

arkan avatar Jun 21 '23 19:06 arkan