- Hands-On GUI Application Development in Go
- Andrew Williams
- 181字
- 2025-04-04 14:54:22
Cross-compilation
Due to the way that libui builds against native widget APIs, the cross-complication is more complicated than a simple Go application. As well as the developer tools that are required for building an application with andlabs UI for the current computer, you will need to have access to the widget library definitions to successfully cross-compile. In some instances, that means a simple library installation, in other cases it may be necessary to install the operating system's Software Development Kit (SDK). Let's look at the details for each target platform.
As with normal Go cross-compilation, we start by setting the environment variable, GOOS (and optionally GOARCH), to define the target platform of our build. To work with libui, we need to turn CGo back on (this is disabled when cross-compiling by default) using CGO_ENABLED=1. Simply executing the build with this setup would likely fail due to a missing library or SDK, as shown here:


Let's look into how cross-compilation can be enabled for various configurations.