ccbuild(1)
okay so bestie, you opened ccbuild(1) and honestly? iconic of you. this is the manual page for ccbuild, the strict C++ developer's build utility, and we're gonna get through it together. part 1 of 2, so buckle up, we are NOT done yet π
β¨ NAME β¨
ccbuild β Strict C++ developerβs build utility
π¦ SYNOPSIS π¦
ccbuild options [command]
πΈ DESCRIPTION πΈ
okay so here's the vibe: ccbuild is a build utility that reads your C++ source. it collects all the source surrounding your local includes and links all of that to your main program. the global include statements (you know, the #include ones) are what it uses to make sure the compiler gets the right arguments. no cap.
the link between compiler arguments and those global includes is made using configuration files. those files contain lines with a global header file name plus the extra arguments the compiler needs to find and use that file. the file name and the arguments are separated by tab character(s) or a space. ccbuild reads these configuration files in order. only the first mention of a global header file in these files is used. usually only ./ccResolutions is used, but there are more possibilities β go check the FILES section for the tea.
ccbuild will follow any local include (#include "something.hh") to try to find more source code to compile. now, if you want to keep ccbuild from following up on an include statement? separate the # sign and the include statement with a single space (# include). that's it, that's the trick π«Ά
π COMMANDS π
build [filename.cc]
Build everything, or just the given source.
lib [filename.cc]
Collect all objects into an archive. if a version is given (via --pversion), then a shared library is also built, with symbolic links. heads up: this currently forces the -fPIC argument addition. the name of your library is given the name of the current directory β or its parent, when the current directory is called src.
Example: create an empty .cc file which simply includes all the local libraries, then run:
ccbuild --pversion 0.0.1 lib that-file.cc
clean [filename.cc]
Clean everything, or the given source.
distclean
Recursively remove all o directories after removing all .md5 and .o files therein. and it removes all .gch files. bye bye π§Ή
deps [filename.cc]
List all files this source depends on. it lists three lines, separated by empty lines:
- the local dependencies
- the ignored headers (for the file)
- all global includes needed
dot [filename.cc]
Generate dot graph files for sources on stdout. if no source file name is given, then for all binary targets in the local directory a .dot file will be created. if the --verbose flag is used, the dot graph will also contain all object file names and their dependencies, plus lists of ignored headers. objects get coloured light grey, binary targets light blue, and ignored headers get a red line. cute little diagram moment π
makefile [filename.cc]
Generate a Makefile on stdout. if no file name is given, an all rule will be generated. otherwise only the rules for the given file are generated.
aap [filename.cc]
Generate an A-A-P file on stdout. if the file name is not given, an all rule will be added and all local binary targets will be listed.
check [filename.cc]
Display source status and file name on stdout. status and source path are separated with a tab character. status is either old or ok. when the --verbose flag is used, another tab separated column will be inserted containing a two letter file type that ccbuild identifies it as. that file type is bt, ot, ih or hh for binary target, object target, internal header and header respectively.
icmake [filename.cc]
icmake slave mode. this will output the used directories, one directory per line. if a CLASSES file already exists, it will only output the class directories not mentioned in the CLASSES file. if --verbose is given, all classes will be listed. the output will not contain directories with only header files. updating the CLASSES is typically done by running:
ccbuild icmake >> CLASSES
resolve [filename.cc]
Print all unresolved globals onto stdout followed by a tab character. these can be appended to the ccResolutions file using:
ccbuild resolve >> ccResolutions
md5 [filename.cc]
MD5 sum all sources needed to compile all binary targets, or the given source, on stdout.
π OPTIONS π
options are used to change the behaviour of the commands. some options are useless for some commands β yeah, it's giving "read the room" energy, but they're all still here.
-f,--force-updateβ update everything by labelling everything asold. gaslight the whole tree into thinking it's stale π-h,--helpβ get a list of options and commands.--gnutouchβ touch files part of the GNU software standard. they will be touched in../, except when there is a directory calledsrcin the current directory, in which case the current directory will be used. this touchesAUTHORS,NEWS,README,INSTALL,COPYING,TODOandChangeLog.-s,--no-actβ simulate, don't really execute any writing commands. pretend build, no cap π--compiler cmdβ set the compiler command. the default isg++.-a,--args argumentβ set these default compiler arguments, removing the standard default arguments (-Wall -g). multiple uses of this option are concatenated with spaces.-C pathβ change directory before anything else.-p,--precompile-ihβ pre-compile only internal headers. this requires g++ version 3.4 up.--precompile-allβ pre-compile both internal headers and normal headers. this requires g++ version 3.4 up. when you use internal headers, this will only slow you down. however, when you don't use internal headers, this pre-compilation is all you've got.--bruteβ continue on compiler errors. stubborn queen energy π--md5β use MD5 hashes to check for file changes. the hashes are stored ino/filename.md5for every file. these sums are only stored after a clean exit fromccbuild(last line showing[WR] MD5 data) or a successful compilation.-I pathβ add this path to the local include search path ofccbuildand the compiler (which will receive the same argument).--recursive-include pathβ this is just like-I, but for the given path and every non-empty directory with a name other thano. > make sure you do not come to depend on this behaviour, that would be bad practice. fr fr, don't do it.-l,--highlightβ highlight the output of the compiler using a red terminal colour.--xof,--exec-on-fail commandβ execute this command when the command (pre)compilation returns anything but0. the first argument given to the command will be the relative path to the file the command was executed on (which is either a C++ source or header). if you don't want to use the file name, you can append an echo command likesleep 2; echo.--xop,--exec-on-pass cmdβ this is the same as--exec-on-fail, except it only works when the command returns0. the first argument given to the command will be the relative path to the file the command was executed on.--clearpcβ clear the screen just before executing the command (clear per command). aesthetic β¨--append cmdβ append this to every command. this can be used to redirect output or set up pipes for compiler output.--loopβ loop the system with one second intervals. this only works for thebuildcommand at the moment. all sources who are touched will be reloaded. if a file is removed, the whole source tree is reloaded.--nodefargsβ do not read the first line of./ccResolutionsfor extra arguments.--nodefresβ do not load anyccResolutionsfiles outside of./ccResolutions. this can be used to create a monolithicccResolutionsfile or discover your project's dependencies with theresolvecommand.--addres filenameβ load the given resolution file before any other.--pversion versionβ set the program version you are working on to version. this is currently only used for thelibcommand. when defined, the library command can make a shared object (.so) and symbolic links by using the version number. > it should not contain any file system special characters like slashes. so keep it cute and slash-free bestie.--arβ archive the objects before linking. this should reduce the binary size because it leaves out unused objects.--verboseβ show commands and produce more output fordotandcheckcommands.-V,--versionβ output version number on stdout and copyright/license on stderr.--xmlβ output in XML where supported. currently this is only thecheckcommand.--nowarnβ leave out most warnings.--batchβ compile a batch of files with one g++ call before any other compilation. this effectively disables any multi-threading, but may speed things up for larger collections of small files. this process involves creating a temporary directory in/tmp/ccbuild_batch.XXXX. > the exact behaviour of this option may change in the future based on performance results and user experience. so like, don't get too attached.-j number_threadsβ set the maximum number of threads used during build. only available when OpenMP is enabled.
π RESOLUTION CONFIGURATION π
the ccResolutions file links global headers to compiler arguments. every line should be either:
- empty,
- start with a comment character
#, or - contain a configuration line.
a configuration line contains the name of the global header, followed by one or more tab characters, and then the additional arguments needed when a source depends on this global header. the arguments are POSIX shell expanded.
and if the first line of the ccResolutions file starts with #&, the rest of this line is shell expanded and used and appended to the argument list of ccbuild. sneaky little bonus line, iykyk π
β¨ EXAMPLES β¨
Okay bestie, this is the part where it gets fun. Real talk, these are actual ways people use ccbuild in the wild, and honestly? Some of these are lowkey genius.
ccbuild resolve >> ccResolutionsβ this one adds every unknown global header to theccResolutionsfile. You can also toss in--nowarnto keepccbuildquiet about it, but heads up: you're gonna have to think twice if you start getting compilation errors. πccbuild --bruteβ the "I just randistcleanand I'm in the pit of despair" move. This updates as many objects as will actually compile, which means you can focus on the errors in your nextccbuildcall instead of drowning. main character recovery arc. πccbuild -p --compilerg++-3.4' --args -Wall --args-Wextra -ansi'β precompiles internal headers usingg++-3.4and highlights all compiler output (-l). Also hands every compiler command the parameters "-Wall -Wextra -ansi". Chef's kiss. β¨ccbuild -f --args -O3β recompiling your whole project for benchmarking tests. Forces the update of all code (-f) and sets the compiler argument to-O3. go off, optimizer. π₯ccbuild --verbose dot; dotty *.dotβ graphs the dependencies for all programs, with colours, then you view them withdotty. This helps you spot irregular dependencies and figure out what your test programs are actually using. It's giving detective era. π΅οΈ- **
ccbuild --xofgedit'** β tries to compile the program and opens the *first* file that doesn't compile correctly. It opens all error-producing sources ingedit`. Super useful when you change the interface of a class and everything explodes at once. π ccbuild --compiler distcc -j 20β use 20distcccompilers to compile the project. twenty. twenty compilers. iconic. π
πΈ FILES πΈ
Configuration files used by ccbuild, bestie. These are the little guys that hold your settings.
./ccResolutions[.USERNAME,.HOSTNAME,.KERNEL_NAME,.MACHINE,]β the local configuration, and it's project specific. It loads the first existing file out of:./ccResolutions.USERNAME,./ccResolutions.HOSTNAME,./ccResolutions.KERNEL_NAME,./ccResolutions.MACHINE,./ccResolutions. You can find the hostname, kernel name and machine withuname -nsm.~/.ccbuild/ccResolutionsβ the global configuration file. π~/.ccbuild/ccResolutions.dβ the resolution configuration directory. Every single file in this directory counts as a configuration file. no cap. π
π CAVEATS π
Okay so this is the part where I hold your hand and tell you the scary things. Please actually read this one.
Do not put any file intoodirectories. These will be removed when you use thedistcleancommand. Gone. Poof. bye bestie π
Also, don't use files with the same basename but different C++ extensions β that gives you problems with the objects created. Like, for example, add.cc and add.cpp in the same directory? That's a no from me.
Currently there is no way to allow one object file to affect the command-line parameters of another. Which means: if all objects need a flag, you must use the --args argument and you can not use a global header resolution line. Examples of these flags that need to be defined everywhere are -pthreads, -mthreads and -threads. Please read the g++ manual for more information on usage of flags. (I know, I know. go read the other manual. it's giving homework.)
ccbuild seems to be incompatible with flex 2.5.4. That version of flex places an int main function in the resulting scanner, and there doesn't seem to be a way to stop it from mentioning it. The result? ccbuild will think the generated scanner is a test program for your class and won't link it into the main program. The solution is to move to a newer version of flex, or find a way to remove the int main function from the resulting scanner file. π
π REPORTING BUGS π
Found something cursed? Report any issue with ccbuild at: https://github.com/bneijt/ccbuild
π« RESTRICTIONS π«
ccbuild will not follow or act on any include statements with a single space between the #-sign and the include. So all include statements starting with # include will be ignored, and all other combinations will be acted on.
And before you @ me: this is a feature, not a bug. periodt. π
In verbose mode (--verbose) these get mentioned as warnings.
π SEE ALSO π
pkg-config(1), dotty(1), make(1), icmake(1), g++(1), aap(1), svn(1)
π AUTHORS π
A. Bram Neijt <bneijt@gmail.com>
and that's the whole page, bestie π«Ά this one came out of the General Commands Manual and it's dated August 8, 2014 β so it's basically vintage, and vintage is always iconic. now go compile something cute. πβ¨π
π¦ where this page comes from
- ubuntu resolute: ccbuild 2.0.11-2 Β· GPL-3.0-or-later
- ubuntu stonking: ccbuild 2.0.11-2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms