Checking all basic development steps

We are not here together to understand the entire details of code compilation. But I want to give you a global explanation that will help you to understand better how it works under the hood. It will also help you to understand how to debug your source code and why something wouldn't work in any random case.

Let's begin by a flowchart showing the entire process.

Checking all basic development steps

From the source code to the binary executable code

The following steps are executed to take the code from the source to the executable production stage:

  1. The C and C++ source code is just the type of code you already wrote for the Blink250ms project in Chapter 1, Let's Plug Things.
  2. Headers are usually included at the beginning of your code, and they refer to other files with the extension .h in which there are some definitions and class declarations. This kind of design, in which you have separate files for the source code (the program you are currently writing) and the headers (already made elements), provides a nice way to re-use your already written code.
  3. The Preprocessor is a routine that basically substitutes text elements in your code, considering the headers and other constants' definitions.
  4. The Parser prepares a file that will be translated, and that file will be assembled to produce multiple object files.
  5. An object file contains machine code that is not directly executable by any hardware processor.
  6. The last important step is the linkage made by the linker program. The linker takes all objects produced by the previous compilation steps and combines them into a single executable file called program.
  7. From the source code to the object file, all processes are summarized under the name compilation.
  8. Usually, libraries provide object files, ready to be linked by the linker. Sometimes, especially in the open source world, libraries come with source code too. This makes any changes in the library easier. In that case, the library itself would have to be compiled to produce the required object files that would be used in your global code compilation.
  9. Hence, we'll define compilation as the whole process from the source code to the program.

I should even use and introduce another term: cross-compilation. Indeed, we are compiling the source code on our computer, but the final targeted processor of our resulting program (firmware) is the Arduino's processor.

Generally, we define cross-compilation as the process of compiling source code using a processor in order to make a program for another processor.

Now, let's move further and learn how we are going to test our initial pieces of C code precisely using the IDE console.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181