fyne-io / fyne-cross

Cross compiler tool for Fyne apps
BSD 3-Clause "New" or "Revised" License
234 stars 48 forks source link

darwin complies windows application failed with 'could not package the Fyne app: exit status 1' #259

Closed xuecangqiuye closed 2 months ago

xuecangqiuye commented 2 months ago

Describe the bug:

darwin complies windows application failed with go-openvpn

It would be helpful if you can give me go build command to try.

To Reproduce:

Steps to reproduce the behaviour:

packaging command: sudo fyne-cross windows -pull -app-id 121.23 then the output is below:

kkl@kklMacBook-Pro-2 openVPNClient % sudo fyne-cross windows -pull -app-id 121.23
Password:
[i] Target: windows/amd64
[i] Checking for a newer version of the docker image: docker.io/fyneio/fyne-cross-images:windows
[✓] Image is up to date
[i] Cleaning target directories...
[✓] "dist" dir cleaned: /app/fyne-cross/dist/windows-amd64
[✓] "temp" dir cleaned: /app/fyne-cross/tmp/windows-amd64
[✓] "bin" dir cleaned: /app/fyne-cross/bin/windows-amd64
[i] Checking for go.mod: /Users/wangshengbin/code_project/go_api/com/openVPNClient/go.mod
[✓] go.mod found
[i] Packaging app...
# github.com/mysteriumnetwork/go-openvpn/openvpn3
In file included from _cgo_export.c:4:
cgo-gcc-export-header-prolog:49:35: warning: redeclaration of 'goStatsCallback' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
extern __declspec(dllexport) void goStatsCallback(user_callback_data ptr, conn_stats cStats);
                                  ^
callback_bridge.go:28:13: note: previous declaration is here
extern void goStatsCallback(user_callback_data usrData, conn_stats stats);
            ^
cgo-gcc-export-header-prolog:50:35: warning: redeclaration of 'goLogCallback' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
extern __declspec(dllexport) void goLogCallback(user_callback_data ptr, char* cStr);
                                  ^
callback_bridge.go:26:13: note: previous declaration is here
extern void goLogCallback(user_callback_data usrData, char * str);
            ^
cgo-gcc-export-header-prolog:51:35: warning: redeclaration of 'goEventCallback' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
extern __declspec(dllexport) void goEventCallback(user_callback_data ptr, conn_event cEvent);
                                  ^
callback_bridge.go:30:13: note: previous declaration is here
extern void goEventCallback(user_callback_data usrData, conn_event event);
            ^
cgo-gcc-export-header-prolog:52:36: warning: redeclaration of 'goNewBuilder' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
extern __declspec(dllexport) _Bool goNewBuilder(user_callback_data cd);
                                   ^
tun_setup_bridge.go:25:14: note: previous declaration is here
extern bool  goNewBuilder(user_callback_data);
             ^
cgo-gcc-export-header-prolog:53:36: warning: redeclaration of 'goSetLayer' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
extern __declspec(dllexport) _Bool goSetLayer(user_callback_data cd, int layer);
                                   ^
tun_setup_bridge.go:27:14: note: previous declaration is here
extern bool  goSetLayer(user_callback_data, int layer);
             ^
.......
error building application: exit status 1
[✗] could not package the Fyne app: exit status 1

Example code:

go mod file:

module openVPNClient

go 1.19

require (
    fyne.io/fyne/v2 v2.4.5
    github.com/mysteriumnetwork/go-openvpn v0.0.23
)

require (
    github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
    gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
)

require (
    fyne.io/systray v1.10.1-0.20231115130155-104f5ef7839e // indirect
    github.com/davecgh/go-spew v1.1.1 // indirect
    github.com/fredbi/uri v1.0.0 // indirect
    github.com/fsnotify/fsnotify v1.6.0 // indirect
    github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
    github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect
    github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
    github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
    github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb // indirect
    github.com/go-text/render v0.1.0 // indirect
    github.com/go-text/typesetting v0.1.0 // indirect
    github.com/godbus/dbus/v5 v5.1.0 // indirect
    github.com/gopherjs/gopherjs v1.17.2 // indirect
    github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
    github.com/pmezard/go-difflib v1.0.0 // indirect
    github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
    github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
    github.com/stretchr/testify v1.8.4 // indirect
    github.com/tevino/abool v1.2.0 // indirect
    github.com/yuin/goldmark v1.5.5 // indirect
    golang.org/x/image v0.11.0 // indirect
    golang.org/x/mobile v0.0.0-20230531173138-3c911d8e3eda // indirect
    golang.org/x/net v0.17.0 // indirect
    golang.org/x/sys v0.13.0 // indirect
    golang.org/x/text v0.13.0 // indirect
    gopkg.in/yaml.v3 v3.0.1 // indirect
    honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
)

main.go

package main

import (
    "fmt"

    "os"

    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/widget"
    "github.com/mysteriumnetwork/go-openvpn/openvpn3"
)

var configFilePath = "client.ovpn"

var OpenVpnSession *openvpn3.Session

func main() {
    myApp := app.NewWithID("10101")
    ipEntry := widget.NewEntry()
    form := &widget.Form{
        Items: []*widget.FormItem{
            {Text: "ip: ", Widget: ipEntry},
        },
        OnCancel: func() {
        },
        OnSubmit: func() {
            fmt.Println("Form submitted")
            ip := ipEntry.Text
            fmt.Println(ip)
            Connect()
        },
        SubmitText: "Connect",
        CancelText: "Clear",
    }
    content := container.NewVBox(
        form,
    )
    //build app
    window := myApp.NewWindow("TEST")
    window.SetContent(content)
    window.ShowAndRun()
    OpenVpnSession.Stop()
}

type loggingCallbacks struct {
}

func Connect() {
    bytes, err := os.ReadFile(configFilePath)
    if err != nil {
        fmt.Println(err.Error())
        os.Exit(1)
    }
    config := openvpn3.NewConfig(string(bytes))

    session := openvpn3.NewSession(config, openvpn3.UserCredentials{}, &loggingCallbacks{})
    OpenVpnSession = session
    session.Start()
    fmt.Println("Openvpn started successfully.")
    err = session.Wait()
    if err != nil {
        fmt.Println("Openvpn3 error: ", err)
    }
}
Device info
andydotxyz commented 2 months ago

does the regular "go build" or "fyne package" work for the local platform before trying the cross-compile?

xuecangqiuye commented 2 months ago

does the regular "go build" or "fyne package" work for the local platform before trying the cross-compile?

Yes, both "go build" and "fyne package" work fine on MAC, and I just bought a windows laptop, "fyne package" can package the app.

andydotxyz commented 2 months ago

Hmm, if this is an Apple Silicon Mac then I would recommend testing the latest development version of fyne-cross as there were some fixes that may be related...

xuecangqiuye commented 2 months ago

Hmm, if this is an Apple Silicon Mac then I would recommend testing the latest development version of fyne-cross as there were some fixes that may be related...

Thanks, but it's intel Mac. I will try it later, and now I use fyne package on my windows laptop, so may be the issue is exist, but it stop bothering me now...