C Container Collection (CCC)
|
Currently, this library utilizes some features that many compilers support such as gcc, clang, and AppleClang, but support is not ready for Windows.
This approach will allow CMake to build the collection from source as part of your project. The collection does not have external dependencies, besides the standard library, so this may be viable for you. This is helpful if you want the ability to build the library in release or debug mode along with your project and possibly step through it with a debugger during a debug build. If you would rather link to the release build library file see the next section for the manual install.
To avoid including tests, samples, and other extraneous files when fetching content download a release.
To link against the library in the project use the ccc
namespace.
Here is a concrete example with an arbitrary release that is likely out of date. Replace this version with the newest version on the releases page.
Now, the C Container Collection is part of your project build, allowing you to configure as you see fit. For a more traditional approach read the manual install section below.
To complete steps 1-3 with one command try the following if your system supports make
.
Or build and install with gcc. However, a newer gcc than the default on many systems may be required. For example, I compile this library with gcc-14.2 as of the time of writing. To set up a CMakeUserPresets.json
file to use a newer gcc, see User Presets.
This will use CMake and your default compiler to build and install the library in release mode. By default, this library does not touch your system paths and it is installed in the install/
directory of this folder. This is best for testing the library out while pointing cmake
to the install location. Then, deleting the install/
folder deletes any trace of this library from your system.
Then, in your CMakeLists.txt
:
You can simply write the following command in your CMakeLists.txt
.
To do so, specify that this library shall be installed to a location CMake recognizes by default. For example, my preferred location is as follows:
Then the installation looks like this.
Now to delete the library if needed, simply find all folders and files with the *ccc*
string somewhere within them and delete. You can also check the build/install_manifest.txt
to confirm the locations of any files installed with this library.
Once CMake can find the package, link against it and include the container header.
The CMakeLists.txt
file.
The C code.
If your system does not support Makefiles or the make
command here are the CMake commands one can run that will do the same.
If you do not like the default presets, create a CMakeUserPresets.json
in this folder and place your preferred configuration in that file. Here is my preferred configuration to get you started. I like to use the newest version of gcc that I have installed.
Then your preset can be invoked as follows:
Documentation is available HERE. However, if you want to build the documentation locally you will need doxygen
and graphviz
installed. Then run:
This will generate documentation in the docs
folder. To view the docs in your local browser, double click the docs/html/index.html
file.