C/C++
Most Banana Pro programs found on the Internet are C/C++ programs. The main reasons for this are speed critical applications: interpreters, such as Python, are much slower compared to compiled programs such as C/C++ ones. In this section, we will have a closer look at the Linux C/C++ compiler called GNU Compiler Collection (GCC). GCC includes frontends for both the C and C++ compiler as well as libraries for these languages. We install the C and C++ compiler with the following command:
sudo apt-get install gcc g++ make
Additionally, we install make
, a utility that helps the compiling and linking of C/C++ files. We again start with a very simply "Hello world!"
example, which we call hello.c
:
nano hello.c
We can then add the following content:
#include <stdio.h> int main(void) { puts("Hello world!"); return 0; }
In the preceding example, we include standard input/output headers (stdio.h
). The main entry point of the program has no arguments (void
) and...