This open-source project aims to collect various C algorithms and data structures, making them available to everyone. We welcome contributions from anyone interested in improving or expanding the project.
- C Algorithms
- GCC or Clang compiler
- CMake
- Conan (optional for some libraries)
To get started with this project:
- Clone the repository:
git clone https://github.com/LeonWandruschka/C_Algorithms.git
- Navigate to the cloned directory and install dependencies (if necessary).
After installation, you can build and run specific algorithms as described below. Use -h
for help on running an algorithm, x
or X
to exit the program, or CTRL+C
for an immediate stop.
You can customize the name of the output folder to suit your needs, moving away from the default build
name. Moreover, you have the option to create build files for different configurations, specifically for release or debug modes. To achieve this, just append /debug
or /release
to the end of your preferred output folder name and adjust the CMAKE_BUILD_TYPE
accordingly to specify the desired build mode.
Libraries dependent on a Conan package will not be built, but all other components will proceed to be compiled as expected.
- Generate build files:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- Build the project:
cmake --build build
To run the executable after building, use: cmake --build build --target runExecutable
For a clean build, add --clean-first
.
- Install conan dependencies:
conan install . -sbuild_type=Release -of=build --build=missing
- Generate build files:
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCONAN=ON -DCMAKE_BUILD_TYPE=Release
- Build the project:
cmake --build build
To run the executable after building, use: cmake --build build --target runExecutable
For a clean build, add --clean-first
.
To run the tests you can use ctest --test-dir ./build/test
from the projects source directory.
To use the conan libraries add the include folder to your IDE.
For Linux and macOS the conan install folder should be located at ~/.conan/
.
For Windows users it should be located under C:\Users\username\.conan\
.
Before starting, ensure that you have either gcc
or clang
installed as your C/C++ compiler. This setup guide will also cover the installation of CMake
for building the project and Conan
for managing external library dependencies.
CMake is crucial for configuring and generating the build files. Follow these steps to install CMake on your system:
- Download and install CMake from the official CMake downloads page. During the installation, if prompted, remember to add CMake to your system's PATH to make it accessible from the command line.
For a faster setup on Linux and macOS, you can use the respective package managers:
-
Linux (Debian-based distributions):
sudo apt update && sudo apt install cmake
-
macOS (Using Homebrew):
brew install cmake
Conan simplifies external library management. Below are the instructions for installing Conan on different operating systems.
- Install Python: Visit the official Python website and follow the instructions to install Python on your system.
- Install Conan With Python installed, open a terminal or command prompt and execute the following command:
pip install conan
- Set Up Conan Profile: Automatically detect and create a Conan profile by running:
conan profile detect --force
- Install Conan: If you have Homebrew installed, you can easily install Conan by running:
brew install conan
- Set Up Conan Profile: Like on Linux and Windows, configure your Conan profile with:
Here's an overview of the project structure:
.
├── CODE_OF_CONDUCT.md
├── CmakeLists.txt
├── Doxyfile
├── LICENSE
├── README.md
├── build
│ ├── release (optional)
│ └── debug (optional)
├── memory
│ ├── CmakeLists.txt
│ ├── include
│ └── src
├── misc
│ ├── CmakeLists.txt
│ ├── include
│ └── src
├── search
│ ├── CmakeLists.txt
│ ├── include
│ └── src
└── src
├── CmakeLists.txt
└── main.c
We welcome contributions! Please see CONTRIBUTING.md for more details on how to contribute to this project.
- Leon Wandruschka - Initial work
Thanks to all the contributors who participate in this project.
This project is licensed under the MIT License - see the LICENSE file for details.
For any inquiries or contributions, please contact Leon Wandruschka.
- Addition of more algorithms and data structures.
- Integration of Conan packages for enhanced functionality.
- Implementation of Catch2 for comprehensive testing.