How-To: Install FlatBuffers

· flatbuffers

This is a post in an ongoing series on FlatBuffers.

FlatBuffers is a project from Google that allows you to encode and decode data at great speed. Here’s a quick tutorial on how to install the compiler flatc, a dependency for developers using FlatBuffers.

Installation with Homebrew on OSX

On my OSX system, I use Homebrew to manage packages. FlatBuffers can be installed with one command:

$ brew install flatbuffers

Personally, I like to install the latest development version from the official Git repository:

$ brew install flatbuffers --HEAD

If successful, you will have the flatc program accessible from your shell. To verify it’s installed, execute flatc:

$ flatc
flatc: missing input files
usage: flatc [OPTION]... FILE... [ -- FILE...]
...

Installation from source

If you’d like to compile from source, you’ll need cmake, make, and a C++ compiler.

Clone the git respository into a new directory, then build and test the project:

$ git clone https://github.com/google/flatbuffers.git
$ cd flatbuffers
$ cmake -G "Unix Makefiles"
$ make
$ ./flattests # this is quick, and should print "ALL TESTS PASSED"

The binary will be located at ./flatc

Installation on Windows from binary release

Retrieving a Windows binary can be done through the FlatBuffers releases page. Grab the latest exe file and you’re all set. Note that the binary must be used with the corresponding release from that page.

Installation on Windows for a Visual Studio project

To use FlatBuffers with Visual Studio, head over to the FlatBuffers installation documentation. You’ll use the Visual Studio project from the official FlatBuffers repository.

About the author

I'm Robert Winslow, a consulting engineer. I help teams launch great products: Learn more.