Do I use the Firebase C++ SDK or the Firebase C++ SDK?

Build from source or pre-built binary? What’s the difference?

Patrick Martin
Firebase Developers

--

Firebase provides a robust cross platform C++ SDK to facilitate integration with games. Should you choose the source based or binary distribution of the SDK?

For most users most of the time, you will want to use the binary version of the SDK. It will be the easiest to integrate, especially if you don’t use CMake as your build system. But I’ll take the time here to weigh pros and cons, and highlight when the open source variant is your ideal choice.

Source Based

There are two important bits of information that you need to know about the open source C++ Firebase SDK:

  1. It’s the same SDK as the binary one. You’re not getting a different implementation or feature set out of some desire for secrecy.
  2. For the desktop versions of the C++ SDK, all of the logic will be contained in this one open source repository. For Android and iOS, much of the heavy lifting is done with additional platform-specific logic. Even though these components are open source, you’ll likely want to pull them in via Gradle or CocoaPods.

Why would you build from source?

If you’re like me, it’s mostly for peace of mind. When I have a really strange error, no matter how much I trust the maintainer of a library, I’ll always wonder if the error isn’t my fault. I may waste hours poking a binary blob to find information that would otherwise be a single step away in my debugger.

Additionally, Firebase is a C++ SDK rather than a C SDK. On Windows and MacOS, the relevant abstract binary interfaces (ABIs) are very stable (as verified by Firebase’s own internal testing). Linux is a different beast, and Firebase can’t control for every distribution’s unique environment. Therefore, if you plan on using the Firebase C++ SDK in your Linux based development environment or in shipping Linux games, you will likely want to build Firebase from source to guarantee compatibility.

Finally, even if you only have iOS and Android support in the pipeline, you may not want to rule out other platforms as an option. The Firebase C++ SDK is not currently recommended for use in shipping games on desktop platforms, but does currently function very well despite its beta state. If you decide to rebuild your game for desktop users, using the open source SDK means that you won’t have to wait on Firebase to implement features or fix bugs that you may come across. If you encounter a need to deploy on platforms not officially supported, it may be easier to port over the desktop SDK rather than having to integrate a new backend. Don’t forget to reach out to Firebase Support in these cases!

Unfortunately, the building from source has some drawbacks. In which case, you’ll want to consider the binary distribution.

Binary

The biggest reason why you may want to use the binary distribution of Firebase is that the open source build process is non-trivial. The base prerequisites to build Firebase may not be readily installed on your developers’ machines, including several Python packages. If you’re planning on building on Windows, packages like Protocol Buffers may not be easy to configure.

The binary distribution of the Firebase SDK is designed to be streamlined for integration for most developers. It’s fairly large, but that’s due to it including binary packages for a wide variety of architectures and environments, including the various C++ STL implementations Android has had over the years. On Windows, it even contains its own Python executable. If you use the CMake build process, all the proper libraries and macros are even resolved automatically when building.

Using the binary variant of Firebase will also improve your build times, especially on a clean build. If you also count not having to configure every developer’s environment with the relevant dependencies, it’s by far the fastest way to go from 0 to cloud for any developer at any state in your game.

Finally, building Firebase from source relies on CMake. The binary distribution supports the legacy ndk-build in addition to CMake. Further, since you really just need the header and binary libraries, it can be much easier to integrate Firebase into atypical build pipelines than it would be to shoe-horn in CMake or duplicate its logic.

Conclusion

As you can see, the binary distribution has many advantages over the open source one for a typical game project. There are still plenty of excellent reasons to use the open source SDK, and neither one is slated for deprecation. Whichever you choose, you get the same Firebase SDK and feature set. Further, the CMake projects for both SDKs share the same target names. This means that if you’re using CMake you can easily start with the binary Firebase and switch to open source if you need. You could even use conditionals to include the open source one in certain circumstances (say for a debug build or only on Linux) with a little bit of work.

Resources

--

--

Patrick Martin
Firebase Developers

I’ve been a software engineer on everything from games to connected toys. I’m now a developer advocate for Google’s Firebase.