Code Monkey home page Code Monkey logo

cpp_watchlist's Introduction

C++ Tools and Libraries

Below are some C++ tools and libraries I find useful.

  • This repository is created for my own reference.
  • I want to keep the list as short as possible.
  • I have not tried all of them.

Package manager

  1. Spack. Spack is to C++ what venv to Python. With spack, different versions of the same C++ library can coexist side by side. They can different by release verions, compiler choice, compiling flags, features switch on/off. The user can painlessly try out as many different combinations as he wants. Spack is a must-have if you have to twist C++ libraies a lot and often have multiple incompatible versions of the same libraries around. It could also be very useful to those who need to deploy many binaries with constant updating of dependencies.
  2. Conan. With Conan, one can use binary libraries without much of pain, and fall back to buiding from source if a certain version of a library is not avalible. Using Conan to install a library is somehow like using apt to install the "dev" version of a package on Debian/Ubuntu. The difference is that Conan is cross-flatform, and also with more configurable options, for example, specifying the verion of a library. More importantly, Conan does not mess with system-wide libraries. It is never a good idea to use a system package manager to manage project dependencies for this reason.

Build tools

  1. CMake. CMake is horrible. I wish I could avoid it. But It has become the de facto building tool used by most C++ libraries because of momentum. No matter what a C++ programmer might think of CMake, he usually need to know some CMake to do his work. If you have to use CMake, it is important to learn some Modern CMake.
  2. Make. Make is even older than CMake, and is often used as the backend for CMake. For small C/C++ projects, simple Makefiles is sufficient to build them. It is important to know the basics of Make.
  3. Ninja. Ninja is like make, but has a smaller scope. It is supposed to be used as a backend by a building system working at a higher level. Since ninja files are not supposed to be manually written, the DSL used by ninja is designed for maximal speed.
  4. Bazel, Bazel is designed to work with multiple langauges and build things at scale. When you have a very large codebase that consists of source code written in multiple programming langauges, to ensure the correctness of building becomes important. Also for very large codebase, remote caching of binary artifacts becomes necessary. Bazel can do this because it uses a server-client archetecture, designed while having scalability in mind. Bazel is best suited for monorepo development.

Library collections

  1. Folly. Folly stands for "Facebook Open-source library". It is actually a collection of useful libraries. If something is missing from the standard library of C++, one might find it in folly.
  2. Abseil-cpp. Abseil-cpp is a collection of C++11 compliant libraries from Google. Many types included in it have replacements in newer versions of C++, while others are designed with different design priorities. For example, absl::Time and absl::Duration are designed to replace std::chrono::time_point and std::chrono::duration in common tasks. They have less capabilites and guarantees but they also don't have to use the template-heavy appraoch that the standard library uses.
  3. Poco. Poco is a collection of C++ libraries that are designed for ease of use. It focuses on network-centric applications.
  4. Boost. A collect of libraries that aim to supplement the standard library.

Memory allocators

Modern implementations of malloc often provide the following extra features besides allocating and deallocating memory chuncks:

  • Leak detection.
  • heap profiling.
  • performance tuning handlers.
  1. Jemalloc, memory allocator from Facebook with better performance with multithreading.
  2. Gperftools, the core of Gperftools is a malloc implementation called Tcmalloc. Besides leak detection, heap detection, performance tuning configurations, It also contains a CPU profiler.

Sanitizers

  1. Google's sanitizer collection. These sanitizers have been integrated into both Clang and Gcc, can be easily enabled with -fsanitize=<feature> compiler options. The collection includes:
    • AddressSanitizer which includes LeakSanitizer (detecting memory leaks), detecting using illegal memory and memory overflow.
    • ThreadSanitizer which detects data races and deadlocks for C++.
    • MemorySanitizer which detects use of uninitialized memory.
    • HWASAN, short for Hardware-assisted AddressSanitizer, which is AddressSanitizer that needs hardware support.
    • UBSan, or UndefinedBehaviorSanitizer.
  2. Valgrind. Valgrind is essentially a tool that construct a virtual-machine-like executing enviroment for comcipled binary executables. When executables are executed in the virtual enviromental, many aspects of the program can be checked at runtime. Valgrind is thus essentially a very advanced trading tool. Though because of its VM-like approach, the performance penalty is big as a tracing tool.

Tracing tools

Many tools mentioned above are also capable of profiling to various extents. They won't be repeated below.

  1. Linux perf tools, a collection of tracing tools built on Linux's ftrace and perf kernel facilities.
  2. strace, roughly equivalent to perf trace in terms of functionality. It is used to trace a process's interaction with the Linux kernel.
  3. SystemTap, system wide probe and trace tool.
  4. bpftrace, like SystemTap with a different design goal with different trade-offs.
  5. Dyninst, An advanced tool to instrument your binary for better analysis.

Profiling tools

  1. Profile-guided optimization. Both Gcc and Clang support the so-called Profile-guided Optimization. Related features can be enabled with compiling options started in the form of -fprofile-<*>.
  2. perf_events, Linux perf command, also known as perf_events, see wiki pages. For example, you can use perf top -p <pid> to get a sorted list of how much time each function in a program consumes. This tool started as a light-weight perforamnce profling tools using Linux perforamnce counters. Later, varous support for tracing was also added.
  3. Gprof, Oudtaed alert, a performance tool based on sampling. It has its limitations, but still can be very useful. This is the old way of performance profling with many restrictions compared with its mordern replacement. The only good thing is that it has built-in support in GCC using the -pg option.
  4. VTune, Intel's profiling tool.
  5. gperftools, as mentioned above, gperftools can also be used for performance profling.

Micro benchmarking

  1. Google benchmark library, a library that is used to benchmark code snippets.

Error handling

  1. Outcome, this library is also part of Boost, but can also be used as a standalone library. The library aims to unifies error handling in C++. Accompaning with the std::error proposal, and the deterministic failure proposal, and the deterministic exception proposal, error handling in C++ can be greatly simplified. It even makes intefacing with C code easier, for example. Though many pieces have yet been put into the langauge standard, the library is usable now.
  2. Boost-LEAF, A library developed as an reaction to Outcome.

Working with binary files:

  1. Tools that inspect binary files
    • readelf, a Linux tool that display information about ETF object files.
    • objdump, a Linux tool that display information about object files.
    • C++filt, a Linux tool to convert mangled C++ names to unmangled names.
    • ldd, a Linux tool to list all shared libraries an executable needs. (Don't use it for executables you don't trust.)
    • ltrace, a Linux tool to trace calls to functions in shared libraries.
    • hexdump and xxd, to view binary files in hex format.
  2. The linker or linkers. The default linker for Linuz is ld, known as the GNU linker. Clang has lld which is a drop-in replacement for ld. It is important to understand how the linker works when working with native programming langauges such as C/C++.

Network libraries

  • asio, asynchronous network programming library, supports serial ports too. It also has SSL support.
  • beast, http ans WebSocket library built upon Asio.

Data storage and quering

If you need a in-process database:

  • SQLiteCpp, a C++ wrapper for the SQLite library, a in-process SQL databse engine.
  • LebelDB, a on-disk key-value data egine.

Unit test

  1. Google Test, the most popular unit test framework.
  2. catch2, a lightweight unit test framwork that allows you to write test along with source code.

Remote procedure call

gRPC, a RPC library using protobuf underneath to serializing structured data.

Message Queue

ZeroMQ, publish and subscribe messages over network.

Image processing

openCV, one can start with its "core", "imgproc" and "imgcodecs" modules.

String formatting

fmt, type-safe alternative for C's printf. Goodbye, idiotic iostream.

Reduce boilerplate

  1. boost operator, part of tis functionality can be replaced by the "space operator" introduced in C++20.
  2. Better enums, working with enums less painfully.
  3. cxxopts, a library for parsing command line options. Note that both Folly and Abseil has their own command line option parsing library, there is also gflags.
  4. cli, creating interactive command line interfaces.

Parse structured text

Data Serialization

  • Protocol buffers, data serialization format from Google.
  • Cap'n proto, a data serialization format that tries to improve on Protocol buffers. This is a zero-copy format.
  • Simple binary encoding, a data serialization format used in the finacial industries. It is also a zero-copy format with different design tradeoffs than Cap'n proto.
  • MessagePack, a data serialization format that does not need separate schema files. It is good for small data transmission between different processes on the same machine. It is less extensible than above formats, but can make simple things simple.

Logging

  1. spdlog, a configurable logging library.
  2. quill, low latency logging library.

Interprocess communication

boost interprocess, shared memory, interprocess synchronization primitives, message queue, mapped file, etc.

Multiple dispatching

Yomm2, multiple dispatching in C++.

Call C++ code from Python

pybind11, a library that makes writing Python wrappers for C++ libraries easier.

Basic Mathematics

  1. GNU Scientific Library. A library to evaluate special mahematical functions, written in C with C++ wrappers.
  2. LibTom, LibTomMath, LibFastTomMath and friends.
  3. TinyExpr, a very small parser for math expressions, written in C.
  4. mp-units, a units library for C++.
  5. boost-numerics, handle annoying integer arithmetic in C++ correctly.
  6. boost-math, a collect of math utilites.
  7. boost-multiprecison, if you need more precision than buit-in types.
  8. xsimd, C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions.

Numerical computation

  1. Eigen, template library for linear algebra. It can also linked against IntelMKL, OpenBlas, Lapack, etc.
  2. CasADi, a symbolic framework for modeling differentiation based problems.
  3. Clip, linear programming library using primal and dual Simplex methods.
  4. SoPlex, exact solution to linear programming library with rational input.
  5. OptimLib, nonlinear programming using derivative-free methods.
  6. Rehearse, programmatically building optimization problem.
  7. SuitSparse, a coolection of sparse matrix algorithms.
  8. xtensor, working with tensors.
  9. stats, a C++ header-only library of statistical distribution functions with R-like syntax.
  10. Ipopt, nonlinear optimization.
  11. autodiff, automatic differentiation.
  12. ceres, solving nonlinear least square problems and constrained nonlinear optimization problem.
  13. CGAL, computational geometry.

Data processing

  1. Dataframe, a C++ library that provides interface and functionality similar to Pandas or R data.frame.

GUI

  1. QT, cross platform C++ GUI framework.
  2. Dear ImGui, direct mode C++ GUI library.

Utility libraries

  1. Boost CRC, compute CRC value of bytes.
  2. Guidelines Support Library, functions and types that are suggested for use by the C++ Core Guidelines maintained by the Standard C++ Foundation.
  3. Strict Variant, throwing move constructor causses problems, so, why not ban it in varaint.
  4. Boost-PFR, iterate over members of simple aggregate types during compile time, no macros needed.

cpp_watchlist's People

Contributors

bylizhao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.