Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between C++ Toolchains and Compilers?

I know there are many compilers like gcc, clang, ninja but I keep hearing about "Toolchains" and so on but I don't understand what they are, like "gnu-toolchain' etc

like image 647
John Avatar asked Dec 23 '22 19:12

John


2 Answers

There are several important terms:

  1. Compiler: the tool that transforms your code into compiled binary format. This usually includes an assembler step which is strictly speaking not really the compiler. Additionally, the tools you invoke are often "drivers" for the compiler/assembler/linker backend and you call them for every step in the build process (including linking). Examples are gcc/g++, clang/clang++, cl, icc/icpc, ...

  2. Assembler: assembles binary code generated by the compiler into a specific object file format (.obj files for Visual Studio, .o files for pretty much everything else). This is often built-in or at least invoked by the compiler when generating object files from source code. E.g. as, ...

  3. Linker: links together object files into an executable file format. This can be either a shared library (.dll/.dylib/.so) or an executable application (.exe). Examples are ld, link, lld, ...

    (3a) "Librarian": the Unix tool ar or the Visual studio tool lib.exe. This just bundles together object files into a thin wrapper format (.a/.lib).

  4. Debugger: tool used to inspect the values of variables defined in the source code at runtime. Examples are gdb, lldb, windbg, ...

  5. Toolchain: All of the above combined together. Debugger may or may not be considered a part of this though.

  6. Build tool: Tool that calls toolchain tools to transform a collection of source files into one or more libraries and executables. E.g. make, ninja, msbuild, xcode-build, ...

  7. Project generator: Takes an "abstract" description of a project and how the source files relate to the output files and generates something a build tool and/or IDE can use as if the project was built up inside that IDE. This makes cross-platform development a lot less painful if done right. Examples are cmake, qmake, premake, ...

  8. IDE: Text editor enhanced with varying levels of language annotation, code navigation, and toolchain integration. Often you can load project files, search for symbols, build, debug, etc. all from one IDE. Examples are Visual Studio, Qt Creator, KDevelop, Xcode, Eclipse, Code::Blocks, ... and with proper array of plugins: Vim, Emacs, VSCode, Atom, Sublime Text, ...

like image 65
rubenvb Avatar answered Dec 25 '22 23:12

rubenvb


A toolchain is a set of tools (such as a compiler, linker, and assembler) intended to build your project. Additional tools, such as a debugger, can be associated with a toolchain. There can be several toolchains available, depending on the compilers installed on your system.

like image 26
Samuel Kimani Avatar answered Dec 25 '22 23:12

Samuel Kimani