-
-
Notifications
You must be signed in to change notification settings - Fork 153
Description
What happend?
I was running into some issues when compiling my ProxySwitcher project. I will provide a Dockerfile
and the basic code-usage for this library, but I was basically just unable to compile (mostly when cross-compiling from linux to windows). Now, I wanted to document what my mistake was and what could be done to avoid this in the future:
Basically, what I think the project is lacking is some more/updated documentation. I was always struggling with the two different sets of installation/deployment steps in the README and the Wiki. Now I notice that it is rough to figure out what dependencies and which versions of those are needed as well.
In my example, using giu@v0.13.0
, in order to cross-compile from linux to windows, I was running a ubuntu:noble
docker container that shipped with both gcc-mingw-w64
and g++-mingw-w64
at around version 13. What I then figured out was that it seems to work perfectly fine on arch-linux, which can easily install the updated v14 via pacman. Additionally, reverting back to giu@v0.12.0
compiles just fine with these tools on ubuntu:noble
.
So now I am trying to see if I should manually install a different version of mingw-w64
's tools, revert back to the older version for now, or stay on arch-linux. I hope this helps someone and I am grateful for the existence of this project. Happy coding!
Code example
gui/config.go
//go:build cgo
package gui
import (
g "github.com/AllenDang/giu"
)
func Config() {
title := "TODO"
wnd := g.NewMasterWindow(title, 400, 200, g.MasterWindowFlagsNotResizable)
wnd.Run(func() {
g.SingleWindow().Layout(
g.Label("TODO"),
)
})
}
Dockerfile
FROM ubuntu:noble AS linux
WORKDIR /app
COPY . .
RUN apt-get update && apt-get install -y \
libgl1-mesa-dev libxxf86vm-dev \
libxrandr-dev libxinerama-dev \
libx11-dev libxcursor-dev \
libxi-dev libglx-dev \
golang gcc
ENV GOBIN $GOROOT/bin
ENV GO_VERSION 1.24.2
ENV GO $GOBIN/go$GO_VERSION
RUN go install golang.org/dl/go$GO_VERSION@latest
RUN $GO download
RUN $GO mod download -x
ENV CGO_ENABLED 1
CMD $GO build -v -o build/
FROM linux AS windows
RUN apt-get update && apt-get install -y \
gcc-mingw-w64 g++-mingw-w64
ENV GOOS windows
ENV GOARCH amd64
ENV CC "x86_64-w64-mingw32-gcc"
ENV CXX "x86_64-w64-mingw32-g++"
CMD $GO build -v -o build/
To Reproduce
- Use
giu@v0.13.0
- Compile the example for linux as follows:
docker build --target linux -t my_image-linux:latest .
docker run --rm -it -v ./build:/app/build my_image-linux:latest
- Works fine and as expected
- Compile the example for windows as follows:
docker build --target windows -t my_image-windows:latest
docker run --rm -it -v ./build:/app/build my_image-windows:latest
- Fails with some missing references for the linker
- Try using
giu@v0.12.0
and it should work just fine.
Version
(latest, which?)
OS
Any