asticode / go-astilectron-bundler

Bundle your Astilectron app with ease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows App Javascript Error (built on MacOs)

bogdanfinn opened this issue · comments

I used the bundler to build my app for MacOS and Windows. This is my bundlers env config:

"environments": [
    {
      "arch": "amd64",
      "os": "darwin"
    },
    {
      "arch": "amd64",
      "os": "linux"
    },
    {
      "arch": "amd64",
      "os": "windows"
    },
    {
      "arch": "386",
      "os": "windows"
    }
  ],

So for MacOs everything works fine. But on Windows i get the following JS error when starting the application:
Bildschirmfoto 2020-11-23 um 00 51 30

I run the app on a AWS EC2 Windows instance (t2.xlarge) because i do not own a windows system myself. I also tried bundling the app on the Windows EC2 Instance directly but there i receive strange errors with x86_64-w64-mingw32/bin/ld.exe. I dont think this has something to do with the bundler itself.

This message usually means the websocket between JS and GO has been abruptly closed.

You should try logging to a file (by using astilectron's Logger attribute) and see what the logs say

Yeah the issue was i built the windows app on my mac and my application uses:
https://github.com/mattn/go-sqlite3

From their Docs: because this is a CGO enabled package you are required to set the environment variable CGO_ENABLED=1 and have a gcc compile present within your path.

Now i need to figure out how to compile from my mac for windows with CGO_ENABLED.

But no issue with this repository. Will close this ticket.

I just want to take the time and comment here the solution. If anyone in the future will have the same problem.
First i got to this stackoverflow answer while researching:

https://stackoverflow.com/a/42299401

After following the steps there i modified my bundler.json to contain the following part:

"environments": [
    {
      "arch": "amd64",
      "os": "windows",
      "env": {
        "CC": "/usr/local/opt/mingw-w64/bin/x86_64-w64-mingw32-gcc",
        "CGO_ENABLED": "1"
      }
    },
    {
      "arch": "386",
      "os": "windows",
      "env": {
        "CC": "/usr/local/opt/mingw-w64/bin/i686-w64-mingw32-gcc",
        "CGO_ENABLED": "1"
      }
    }
  ],
  "build_flags": {
    "-buildmode=exe": ""
  }

After that it worked for me.

Be aware: this are "my" paths and my use case was to build the application on a MacOS System for a Windows System.

Afterwards i could successfully run my application on a Windows EC2 instance.