-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Description
Let me start by saying that I'm not sure this is actually a bug, but if anything, it's something insufficiently documented...
Assume a naive example project I plan to build for Windows while running under Linux. Simply running the setup.sh script as described in README produces no useful results:
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/webui-dev/go-webui/main/setup.sh)"
go: finding module for package github.com/webui-dev/go-webui/v2
go: downloading github.com/webui-dev/go-webui v0.1.0
go: found github.com/webui-dev/go-webui/v2 in github.com/webui-dev/go-webui/v2 v2.4.2
go: upgraded github.com/webui-dev/go-webui/v2 v2.4.2 => v2.4.3-0.20240711195955-8001a5e84f7d
$ go build
# github.com/webui-dev/go-webui/v2
../../../.local/golang/pkg/mod/github.com/webui-dev/go-webui/[email protected]/cgo.go:14:10: fatal error: webui/src/civetweb/civetweb.c: No such file or directory
14 | #include "webui/src/civetweb/civetweb.c"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
I'm trying to patch the library in by making a local copy as described here:
require (
...
github.com/webui-dev/go-webui/v2 v2.4.3
)
replace github.com/webui-dev/go-webui/v2 v2.4.3 => ../vendor/go-webui/v2
At this point, go build produces a native binary that runs. Which is nice, but cross-compilation is mission critical (and the reason I picked Go for this project in the first place), so...
$ GOOS=windows GOARCH=amd64 go build
....
imports github.com/webui-dev/go-webui/v2: build constraints exclude all Go files in ...Not big surprise here, because that's only supposed to work on projects not making use of cgo. Ok, let's try it with explicitly invoking cgo...
$ GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX=x86_64-w32-mingw32-g++ CC=x86_64-w64-mingw32-gcc go build -v
...
/usr/lib/go-1.22/pkg/tool/linux_amd64/link: running x86_64-w64-mingw32-gcc failed: exit status 1
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lWs2_32: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lOle32: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lAdvapi32: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lShell32: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lUser32: No such file or directoryNow this is quite cryptic, and googling does not appear to produce any clues on what could possibly be wrong. Initially I assumed I just had a misconfigured mingw32 or something, but then I try xgo (https://github.com/techknowlogick/xgo) which is supposed, in theory, to take care of everything for me, and carries everything inside a docker image:
$ $ xgo --targets=windows/amd64 .
Checking docker installation...
Client: Docker Engine - Community
Version: 27.0.3
API version: 1.46
Go version: go1.21.11
Git commit: 7d4bcd8
Built: Sat Jun 29 00:02:33 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 27.0.3
API version: 1.46 (minimum version 1.24)
Go version: go1.21.11
Git commit: 662f78c
Built: Sat Jun 29 00:02:33 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.18
GitCommit: ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
runc:
Version: 1.7.18
GitCommit: v1.1.13-0-g58aa920
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Checking for required docker image techknowlogick/xgo:latest... found.
Cross compiling local repository: . : ...
Enabled Go module support
Building /source/go.mod...
Compiling for windows-4.0/amd64...
......
/usr/local/go/pkg/tool/linux_amd64/link: running x86_64-w64-mingw32-gcc-posix failed: exit status 1
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lWs2_32
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lOle32
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lAdvapi32
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lShell32
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lUser32
collect2: error: ld returned 1 exit statusNotice the identical error message. Which suggests the problem is somewhere in go-webui...
Expected Behavior
I do expect cross-compilation to work or a statement that it isn't supported to be present in the documentation.
Reproduction Steps
No response
Error Logs
No response
Possible Solution
No response
Version
2.4.3
Environment Details (OS name, version, etc.)
Linux 6.9.9-1-liquorix-amd64 x86_64 GNU/Linux
Ubuntu 22.04