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:

Building on macOS for Linux fails
A Linux computer failing to compile for macOS

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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.117.212