Reader small image

You're reading from  Building Cross-Platform GUI Applications with Fyne

Product typeBook
Published inJan 2021
PublisherPackt
ISBN-139781800563162
Edition1st Edition
Tools
Right arrow
Author (1)
Andrew Williams
Andrew Williams
author image
Andrew Williams

Andrew Williams graduated from the University of Edinburgh in 2003 with a bachelor's degree, with honors, in computer science. After university, he went to work as a software engineer and has gained over 15 years of commercial software development experience across a variety of programming languages, including Java, C, Objective-C, and Go. Andrew has spent many years working as a CTO with many early-stage and growing software start-ups. He has been a core developer in large open source projects, including Enlightenment, EFL, and Maven, as well as involved in maintaining various community websites and tutorials. Andrew's passion for building tools and services that make software development simpler led him to start authoring books on the subject.
Read more about Andrew Williams

Right arrow

Appendix C: Cross-Compiling

When building applications that need access to native APIs and graphics hardware, we can use CGo. Although not much harder to build for regular development, this does make cross compiling much more complicated. For every target platform you want to build for, there must be a C compiler that knows how to create native binary files. This appendix outlines the steps required to set up cross compilation targets for each combination referenced earlier in this book.

Important note

Please note that cross compiling is not required for day-to-day development. For most development, you won't require the cross-compiler setup. The Go compiler and standard tools discussed in Appendix A: Developer Tool Installation, are all that you require to develop for standard computers. This appendix is all about installing additional tools for creating compiled applications for a different operating system or architecture than your current computer.

We will cover two...

Manually installing compilers

Installing compilers and toolchains is complex, but this appendix will attempt to guide you through the main steps. This approach is sometimes preferred by developers who want to manage every single detail of their computer. It may also be easier if your computer has previously been used for C development and creating native apps for multiple platforms.

Preparing to build for a different target varies, depending on the system you want to compile for. We'll start by looking at macOS, before exploring Windows and Linux afterward. It is not necessary to follow these steps to build mobile apps since we installed these tools in Appendix B: Installing Mobile Build Tools.

Cross compiling for macOS

When cross compiling for macOS, it's necessary to install the Software Development Kit (SDK) from Apple, as well as a suitable compiler. The instructions for Windows (using MSYS2, as described in Appendix A, Developer Tool Installation) and Linux...

Using fyne-cross

To make it easier to manage the various development environments and toolchains required for cross-compiling a project, we can use the fyne-cross command. This cross-compiling utility uses Docker containers to download and run the development tools of different operating systems, right from your favorite desktop computer.

Installing fyne-cross

Before you can install fyne-cross, you will need a recent version of Go (at least 1.13) and must have Docker installed. On macOS and Windows, there is a Docker Desktop application that can help you manage your Docker setup, while on Linux, most distributions have a docker package readily available. More information about working with Docker is available in Chapter 9, Bundling Resources and Preparing for Release.

Once Docker has been installed, you can use the standard Go tools to install fyne-cross. The following command will be sufficient:

$ go get github.com/fyne-io/fyne-cross

The fyne-cross binary will be installed...

Why subscribe?

  • Spend less time learning and more time coding with practical eBooks and videos from over 4,000 industry professionals
  • Improve your learning with Skill Plans built especially for you
  • Get a free eBook or video every month
  • Fully searchable for easy access to vital information
  • Copy and paste, print, and bookmark content

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at packt.com and, as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Building Cross-Platform GUI Applications with Fyne
Published in: Jan 2021Publisher: PacktISBN-13: 9781800563162
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Andrew Williams

Andrew Williams graduated from the University of Edinburgh in 2003 with a bachelor's degree, with honors, in computer science. After university, he went to work as a software engineer and has gained over 15 years of commercial software development experience across a variety of programming languages, including Java, C, Objective-C, and Go. Andrew has spent many years working as a CTO with many early-stage and growing software start-ups. He has been a core developer in large open source projects, including Enlightenment, EFL, and Maven, as well as involved in maintaining various community websites and tutorials. Andrew's passion for building tools and services that make software development simpler led him to start authoring books on the subject.
Read more about Andrew Williams