I’m not going to start off this post with a description of what C++ is, how old it is (40, in case you were wondering), the fact it’s a high/low-level (the dispute is still on) programming language, and so forth. If you’re looking into C++ libraries, you probably know all that stuff. C++ has grown a lot of libraries that are extremely useful for real-world system development. You may already know some of them, even to the extent of knowing its quirks and idiosyncrasies.
The only problem is, since C++ is not a new language, and it has a large community in stack, there are many libraries you can make use of, so choosing the right ones can be quite a challenge.
My intention is not to go deep into the libraries themselves, but to introduce you to the ones that I believe are important enough to know about in 2021 and beyond. Let us get started.
1. The C++ Standard Library – the Crème De La Crème of C++ Libraries
The mere mentioning of The C++ standard library, made you immediately think about STL, didn’t it? As a part of the standardization of the C++ language, it is not just the language but also a standard library that is provided with the blessing of the International Organization for Standardization (ISO). Here is the current status of C++ and its libraries directly from https://isocpp.org/std/status
Let’s talk about the FileSystem library. It provides facilities for performing operations on file systems and their components like paths, directories, and regular files. In C++14, this library was experimental and as of C++17, this is a part of the standard library. To be precise, the namespace is no longer std::experimental::filesystem, but std::filesystem. It is always best to use facilities provided by the standard library as the behavior is well defined in all different platforms where C++ is supported.
So, what about STL? Standard Template Library is a subset of the standard library that deals with containers, iterators, and algorithms. STL is a generic library that provides solutions to managing collections of data with modern and efficient algorithms. I would say the C++ standard library including STL, is the daily bread and butter of a C++ programmer.
Of course, the next on the list should be Boost. I discussed the FileSystem library in the previous section. The standard FileSystem library was based on the Boost FileSystem library. There are many other instances where Boost libraries were adopted to the C++ standard library. This should speak volumes about the quality of Boost. Boost is a free and open-source peer-reviewed library distributed under a very permissive Boost Software License. It is a set of well-recognized C++ libraries, by various authors, that contain packages of code for the purpose of supporting linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, string and text processing, and unit testing. Downside? Boost is a large and complex library with a steep learning curve. Linking to Boost will also increase your executable size.
POCO C++ libraries are powerful cross-platform C++ libraries designed specifically for ease of use and performance. Poco stands for Portable Components which fits the functionality it offers: building network-centric, and internet-based portable applications. Due to its modular design Poco library is well suited for embedded development (in industries such as IoT, automotive, security, Industrial automation and so on). As for licensing, they have an open-source version which is licensed under Boost software license 1.0. They also have a pro version that is subscription-based which has a commercial source code license. You can download POCO from GitHub.
OpenSSL is the swiss army knife for cryptography. It includes general-purpose full-strength cryptographic routines in its libcrypto component and implementation of all TLS protocols in its libssl component. It is a C library but it is so important in cryptographic applications that I am including it here. Rarely does a bug in a library get noticed by the whole world, and rarely still does it get a webpage of its own. When the heartbleed bug was disclosed, the software world took notice. You can read all about it here.
You would have used FFmpeg if you have done any audio and video processing. In addition to the command line executable ffmpeg, the project also includes a set of high-quality libraries for functions like encoding and decoding for audio/video codecs, demuxers and muxers for multimedia container formats, media filers, image scaling, and color space format conversion operations among others. It is a free and open-source library distributed under the GNU LGPL V2.1 license.
SQLite is a C-language library that implements a full-featured, self-contained, ACID-compliant SQL database engine. It is the most used database engine in the world and hence is a very important library to be aware of. The source code of SQLite is in the public domain and is free for use for everyone for any purpose! This is a unique library usually compiled into the client application through a single source code file called an amalgamation.
7. Dear ImGui
Dear ImGui is a great graphical user interface library for C++ as can be seen from the number of applications using it here. It is fast, portable, render agnostic, and self-contained. Its design goals are simplicity and productivity which makes it particularly suited for game engines, real-world 3-D applications, full screen, and embedded applications. It is open source under a free and permissive license and is available for download through this link.
8. JSON for Modern C++
JSON for modern C++ is a single header library for working with JSON in C++. It is one of the best C++ libraries that I have used for working with JSON. It has an intuitive syntax and a permissive MIT license. Since this is a header only library and implemented in a single json.hpp header file, the integration with this library is trivial.
A lot of C++ programmers prefer GoogleTest for unit testing. GoogleTest is an open-source, well-maintained xUnit test framework, and library for C++. It includes a mocking framework which is great for shift left scenarios.
10. Eclipse Mosquitto
If you had a chance to work with the MQTT protocol in C++, you would have used Eclipse Mosquitto. MQTT is a lightweight and efficient protocol that requires minimal resources and hence suitable for low-power devices like small microcontrollers. The architecture of MQTT is publish/subscribe with MQTT clients talking to an MQTT broker. The Eclipse Mosquitto library is available here and has utilities for both publishers and subscribers.
I have only good things to say about Open CV (check out my blog post about CMake, OpenCV and Unit Tests). There are many C++ libraries for image manipulation and computer vision, but nothing matches the versatility of OpenCV. It features a real-time computer vision, machine learning, and deep learning library for face recognition, object detection, and 3-D model extraction. It is a well-established and well-maintained library with a permissive open-source Apache license.
12. oneAPI Threading Building Blocks
The Threading Building Blocks library developed by Intel is now open-sourced and renamed as oneAPI Threading Building Blocks (oneTBB). It lets you write parallel C++ programs that take full advantage of modern multicore processors that are portable, composable, and future-proof. It has a very permissive open-source Apache 2.0 license and you can check it out here.
Unless you were in a cave for the last five years, you would have heard about Tensorflow. It is a framework written in C++ for machine learning, which includes excellent C++ libraries for doing many of the common tasks encountered in developing a machine learning model. It was originally developed by researchers in the Google Brain team working on problems in machine learning and deep neural networks. It has a very permissive open-source Apache 2.0 license and is available here.
C++ Libraries Are the Real Deal
I love C++ for its myriad characteristics that make it an enterprise programming language. More than anything, I love the libraries that the C++ ecosystem offers for tasks that make development a breeze. I admit, I also love the notion of code libraries. Reusing code by utilizing C++ libraries is brilliant for productivity and code quality (C++ productivity is something we, at Incredibuild, appreciate greatly). Instead of reinventing the wheel each time you need a certain functionality, you’ve got these beautiful pieces of code.
Of course, there are many other great (amazing even) libraries I have not covered (such as GTK+, WxWidgets, Vulcan, ATL, JUCE, HandBrake and so forth). The list is endless but my time is limited. Forgive me for the omissions. A good source to find other C++ libraries is the cppreference.com, however, the libraries listed here are my top picks.
Whether you’re in need of GUI, machine learning, math, audio, common classes or anything else you can think of, I tried including the best library for it on this list.
May C++ live for another forty years! ?