c_build is a package manager and build system for c/c++, that aims to simplify and automate the process of managing and building c/c++ applications, similar to cargo for rust or npm for Javascript. It also makes the projects self-contained, by installing all dependencies locally.
commands:
c_build init`
This command creates a c_build_config.json file and a c_build_modules directory. The config file has sdl2 installed by default as a placeholder for other libraries. It also links math and std
sudo c_build install
This command install all dependencies to the project to c_build_modules. Note that make, cmake and git are required for this command to work
sudo c_build compile
This command compiles the code, linking the installed libraries to c_build_modules
sudo c_build run
This command compiles and runs the code
The default config file looks like this
{
"input": "main.cpp",
"output": "main",
"libs": [
{
"name": "SDL2",
"git_url": "https://github.com/libsdl-org/SDL.git",
"build_command": "cmake -S . -B build && cmake --build build && cmake --install build"
}
],
"std": [
"lstdc++",
"lm"
]
}
- input specifies the main c/c++ file
- output specifies the name of the exported binary
- libs specifies all the external dependencies
- name is the name of the dependency, as will be used by the compiler
- git_url expects a valid url for
git clone
- build_command will be used to compile the binary. It is usually specified within the library's repo. If it isnt, it is usually
make
- std specifies the std libraries to link. Altough not what it is intented for, you can also add any compiler flag here. They will be used in the same order as you input them
- c_build_modules folder is not meant for maual manipulation. A
remove
command will be added to remove broken dependencies c_build init
does NOT create a .gitignore, I recommend adding c_build_modules to gitignore.