Programming for EFI:
Preparing a Development Environment

by Roderick W. Smith,

Originally written: 5/3/2013; last updated: 5/15/2013

I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!

Donate $1.00 Donate $2.50 Donate $5.00 Donate $10.00 Donate another value
Donate with PayPal
Donate with PayPal
Donate with PayPal
Donate with PayPal
Donate with PayPal

Note: This page is a sub-page of my Programming for EFI document. If a Web search has brought you here, you may want to start at the introductory page.

To write an EFI program, you must install suitable development tools. As of mid-2013, two such tools are widely available and under active development:

Because of the complexity and strangeness (to a Linux programmer's eyes) of the TianoCore EDK II, I've chosen to use the GNU-EFI toolkit as the reference for these Web pages. The TianoCore toolkit may be preferable for some purposes, though, such as if you need to access certain advanced or very new EFI features, which the GNU-EFI toolkit supports poorly or not at all. As you'll learn, GNU-EFI also requires awkward wrapping of certain function calls. If it were easier to install and use under Linux, I would recommend TianoCore EDK II over GNU-EFI; but for a Linux programmer just starting out with EFI programming, GNU-EFI gets the nod because of its lower barrier to entry.

If you're using a recent Linux distribution, chances are you can install GNU-EFI by using your package system to install a package called, appropriately enough, gnu-efi. If you're using a distribution from before 2013, though, beware: Many distributions allowed their GNU-EFI packages to become hopelessly out of date by mid-to-late 2012. As I write, the current version of GNU-EFI is 3.0t. (GNU-EFI version numbers have been stable at 3.0 for years, with the following digit denoting improvements.) Changes with recent versions are critical for enabling some features to work, as well as to enable signing an EFI application with a Secure Boot key. Unfortunately, versions 3.0s and 3.0t often produce binaries that hang when launched. According to a GNU-EFI bug report, this problem can be overcome by adding the -DGNU_EFI_USE_MS_ABI compiler flag, but this hasn't worked for me. Thus, if you run into problems, I recommend downgrading to version 3.0r.

If you're not using Linux or if your distribution has no GNU-EFI package or a very outdated GNU-EFI package, you can download the source code from the GNU-EFI Sourceforge page. You can then follow its own instructions to compile and install the software.

No matter how you install GNU-EFI, you'll need additional tools, including a C compiler and the make utility. I've using GCC 4.6.3 and 4.7.2 on Gentoo and Fedora systems, respectively, as references for this page, but other versions of GCC should work, too. I'm not sure about Microsoft's C, Clang, or other compilers.

Unfortunately, you have little choice of language in EFI programming. Both GNU-EFI and TianoCore EDK II support C and nothing else—at least officially. The stumbling block for using other languages is in the libraries; you'd need to port libstdc++ to EFI to use GCC's C++ compiler, for example. This is a non-trivial task that has not yet been undertaken, to the best of my knowledge. (Intel apparently has a C++ compiler for EFI, but it's quite pricey and it compiles to an EFI-specific cross-platform code format.)

Go on to "Creating a 'Hello, World' Program"

Return to the "Programming for EFI" main page

copyright © 2013 by Roderick W. Smith

If you have problems with or comments about this Web page, please e-mail me at Thanks.

Return to my main Web page.