asticode / go-astilectron-bundler

Bundle your Astilectron app with ease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bundling failure when application imports package using go-gl

sereeena opened this issue · comments

I have an astilectron bootstrapped application where I've been successfully using the bundler. When I recently modified one of my packages to use github.com/llgcode/draw2d/draw2dgl for drawing purposes, the inclusion of this package (which under the hood uses github.com/go-gl/gl/v2.1/gl) causes bundling to fail. (If I comment it out it works fine).

Here's the output of my astilectron-bundler call:

2021/05/28 14:24:15 Bundling for environment linux/amd64
2021/05/28 14:24:15 Binding data
2021/05/28 14:24:15 Removing /tmp/astibundler/bind
2021/05/28 14:24:16 Creating /tmp/astibundler/bind
2021/05/28 14:24:16 Creating /tmp/astibundler/bind/vendor_astilectron_bundler
2021/05/28 14:24:16 Creating /tmp/astibundler/cache
2021/05/28 14:24:16 /tmp/astibundler/cache/astilectron-0.38.0.zip already exists, skipping download of https://github.com/asticode/astilectron/archive/v0.38.0.zip
2021/05/28 14:24:16 Copying /tmp/astibundler/cache/astilectron-0.38.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
2021/05/28 14:24:16 /tmp/astibundler/cache/electron-linux-amd64-6.1.2.zip already exists, skipping download of https://github.com/electron/electron/releases/download/v6.1.2/electron-v6.1.2-linux-x64.zip
2021/05/28 14:24:16 Copying /tmp/astibundler/cache/electron-linux-amd64-6.1.2.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
2021/05/28 14:24:16 Creating /tmp/astibundler/bind/resources
2021/05/28 14:24:16 Copying /home/ubuntu/go/src/oncotrack/cmd/oncotrack-client/resources to /tmp/astibundler/bind/resources
2021/05/28 14:24:16 Generating /home/ubuntu/go/src/oncotrack/cmd/oncotrack-client/bind_linux_amd64.go
2021/05/28 14:24:19 Removing /home/ubuntu/go/src/oncotrack/artifacts/linux-amd64
2021/05/28 14:24:19 Creating /home/ubuntu/go/src/oncotrack/artifacts/linux-amd64
2021/05/28 14:24:19 Building for os linux and arch amd64 astilectron: 0.38.0 electron: 6.1.2
2021/05/28 14:24:19 Executing go build -ldflags -X "main.AppName=oncotrack-client" -X "main.BuiltAt=2021-05-28 14:24:19.372772238 +0930 ACST m=+3.388932784" -X "main.VersionAstilectron=0.38.0" -X "main.VersionElectron=6.1.2" -o /home/ubuntu/go/src/oncotrack/artifacts/linux-amd64/binary .
2021/05/28 14:24:19 bundling failed: bundling for environment linux/amd64 failed: building failed: build github.com/go-gl/gl/v2.1/gl: cannot load github.com/go-gl/gl/v2.1/gl: no Go source files

Is there a way to further debug the issue with the bundler build? If I run go build, or even if I execute the go build command with the same ldflags as the bundler, it builds correctly. I'm not sure what I could be doing wrong?

@sereeena the first thing that comes to mind is that you have different environment variables when you execute go build manually. Could you paste the output of go env here? That may be a module-related issue...

Discard my previous comment, it seems to be related to the mandatory use of CGO with the gl package.

You'll need to set the CGO_ENABLED environment variable to 1 as well as CC and CCX.

Check out this comment to see an example of using those environment variables.

Oh thank you, setting CGO_ENABLED fixed the build on linux, but I'm still getting an error on the windows build

2021/05/31 16:59:25 bundling failed: bundling for environment windows/amd64 failed: building failed: # runtime/cgo
gcc: error: unrecognized command line option ‘-mthreads’; did you mean ‘-pthread’?

Do I need some further environment variables to be set?

Per this comment you need to set specific CC and CCX values for windows

Thank you, I was unfamiliar with CGO and cross compilation.
After installation of mingw toolchain on linux (sudo apt-get install gcc-mingw-w64) I was able to build for windows with CC=x86_64-w64-mingw32-gcc, CXX=x86_64-w64-mingw32-g++

Thanks again, will close this issue!