Open dergyitheron opened 1 year ago
I'm also cross compiling from ubuntu docker to windows. After updating wails cli to v2.0.0 I started facing the following error
» GOOS=windows GOARCH=386 wails build -platform windows -debug -ldflags "-w -s -H windowsgui -X main.version=dev -X main.env=business" -o launcher.exe
Wails CLI v2.0.0
App Type: desktop
Platforms: windows
Compiler: /usr/local/go/bin/go
Skip Bindings: false
Build Mode: Debug
Obfuscated: false
Skip Frontend: false
Compress: false
Package: true
Clean Build Dir: false
LDFlags: "-w -s -H windowsgui -X main.version=dev -X main.env=business"
Tags: []
Race Detector: false
Output File: launcher.exe
Building target: windows/386
----------------------------
- Generating bindings: Error:
fork/exec /var/folders/92/821w0x2x71g33yrjsmhlq7q00000gp/T/wailsbindings: exec format error
Removing GOOS/GOARCH and adding -platform windows/386
as @stffabi suggested I get:
» wails build -platform windows/386 -debug -ldflags "-H windowsgui -X main.version=dev -X main.env=business" -o launcher.exe
Wails CLI v2.0.0
App Type: desktop
Platforms: windows/386
Compiler: /usr/local/go/bin/go
Skip Bindings: false
Build Mode: Debug
Obfuscated: false
Skip Frontend: false
Compress: false
Package: true
Clean Build Dir: false
LDFlags: "-H windowsgui -X main.version=dev -X main.env=business"
Tags: []
Race Detector: false
Output File: launcher.exe
Building target: windows/386
----------------------------
- Generating bindings: Error:
package github.com/xxx/launcher
imports golang.org/x/sys/windows: build constraints exclude all Go files in /Users/yyy/go/pkg/mod/golang.org/x/sys@v0.0.0-20220114195835-da31bd327af9/windows
package github.com/xxx/launcher
imports golang.org/x/sys/windows/svc: build constraints exclude all Go files in /Users/yyy/go/pkg/mod/golang.org/x/sys@v0.0.0-20220114195835-da31bd327af9/windows/svc
package github.com/xxx/launcher
imports golang.org/x/sys/windows/svc/mgr: build constraints exclude all Go files in /Users/yyy/go/pkg/mod/golang.org/x/sys@v0.0.0-20220114195835-da31bd327af9/windows/svc/mgr
exit status 1
I feel like I'm doing something wrong? Haven't tested manual builds yet. But I also manage to build on my windows pc
I'll investigate this tonight. It should be something trivial. Just FYI windows/386 is only supported on a best effort basis. Does the 64bit version compile ok?
Yes, I'm aware of that, thanks! I get the same error with windows/amd64
as well
When using GOOS=windows GOARCH=386
for starting wails, the default environment contains those env variables. When we are building the bindings, we initiate a go build
with custom "binding" build tags. In this case GOOS/GOARCH will be implicitly passed over to the go build
and as a result the bindings binary is targeted to that GOOS and GOARCH. As soon as we want to start the binary to build the bindings, this won't work since the host platform is Linux but the binary was built for Windows.
@stefpap in your case when leaving away the GOOS/GOARCH the bindings binary is now built for Linux so it could be started on host. The problem now seems like the bindings app can't be generated for Linux because the imports of imports golang.org/x/sys/windows
are fully excluded due to the Linux target but the import is not constraint to a Windows only build. You should see the same problem when just using go build
in the docker container in the folder where main.go
is.
If you have the bindings already generated as part of your codebase, you could try skipping them using wails build -skipbindings
Hi guys,
today I've tried latest version of wails 2.2.0 with go go version go1.19.3 linux/amd64. Still no luck on builds targeting windows/amd64.
The only difference is that I now get different error when building with same flags as in the original post, "To Reproduce" section, paragraph 4.
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" wails build -ldflags '-extldflags "-static"'
Screenshot:
ERROR: Cannot open assembly '/tmp/wailsbindings': File does not contain a valid CIL image. exit status 2
Any idea why would wails be looking for /tmp/wailsbindings
? I've monitored the /tmp
directory during the unsuccessful build and the file is not present.
Other things stay the same - building with go build
works with same command as mentioned, using wails build -platform
still shows same errors. Build targeting linux/amd64 works fine.
Have you tried to skip the building of your bindings with -skipbindings
? For generating the bindings, a binary is build and executed. Since you are using GOOS and GOARCH the generated binary is a windows binary, which can't be executed on Linux.
I have just tried env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" wails build -ldflags '-extldflags "-static"' -skipbindings
and it's built successfully, runs on Windows but it doesn't function as it should, works on linux and the previous version built with beta v2 works too.
What does the -skipbindings
do? I don't see it in the CLI Reference page. The CLI help command only says 'Skips generation of bindings', I don't know what that means to be honest. Could it be related to how the confluent-kafka-go library needs librdkafka C library in order to compile? That's the main reason I'm using mingw32.
Update: It looks like the issue with windows build is now solved and the app not working on windows correctly is purely networking issue.
The final command that worked: env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" wails build -ldflags '-extldflags "-static"' -skipbindings
with v2.2.0.
I still have couple of questions:
-skipbindings
do? What bindings does it skip? Could it cause problems somewhere else?-platform windows/amd64
not behaving same way as GOOS=windows GOARCH=amd64
? I use the latter just because the former is not working, as described in my previous comments.
Description
I am doing cross compilation targeting windows amd64. My application uses confluent-kafka-go package which needs mingw for compilation for windows.
The compilation worked in beta versions and now doesn't work with
wails build
command. I also tried to usego build
with same flags and it works without an issue and the app runs on windows as expected.Building for linux works just fine.
To Reproduce
Having new wails 2.0.0
wails init
, add confluent-kafka-go package and add some code from the official examplesgcc-mingw-w64
andg++-mingw-w64-x86-64
with for examplesudo apt-get install gcc-mingw-w64 g++-mingw-w64-x86-64
wails dev
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" wails build -ldflags '-extldflags "-static"'
(fails)Alternatively, compile the app with the following command
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" go build -tags desktop,production -ldflags '-extldflags "-static"'
(ok)Expected behaviour
wails build
cross compilation should work same way manual build doesScreenshots
Building with
-platform
flag even yields different errorsHere is the successful build with
go build
. I have a windows server where I tried thekafka-tester.exe
executable and it works as expected.Building for linux works just fine
Attempted Fixes
I tried the manual build by following these instructions: https://wails.io/docs/guides/manual-builds/#compile-application
That worked just fine.
System Details
uname -a