Home RASPBERRY PI How to Compile C++ Programming in Raspberry Pi

How to Compile C++ Programming in Raspberry Pi

0

In this post, I will show you how to install a C ++ development environment on the Raspberry Pi, set it up and use it in a first small project. The Raspberry Pi is above all known for the Python development, but you can also work very well with the most important high-level language C / C ++. With the right IDE (development environment), working is made much easier. Beginners will find everything they need in C ++ books to start their own C / C ++ development.

Raspberry Pi C ++ development environment

Since my studies I have not studied C ++ anymore and would, therefore, like to spend more time in the coming weeks and months on the topic, after all, that’s a “developer blog”. The best-known IDE for C / C ++ development under Linux is CodeLite, which has been quite easy to install with the package manager for some time:

 sudo apt-get install codelite

C++ Raspberry Pi

CodeLite

Sure, the tough guys argue that you can also write source code on the command line and compile with gcc. However, a good IDE makes sense for the meaningful application and the development is thereby accelerated and simplified. The right and best IDE does not exist, that is often a matter of taste. CodeLite is currently my favorite. After installation you will find the development environment in the developer menu:

C++ Raspberry Pi

The program recognizes all installed C compilers and offers them for selection. GCC is usually already installed, if not you can change it with the following command:

sudo apt-get install build-essential

For beginners, this is often confusing, but there are different C compilers. These differences are minimal in the way source code is translated into an executable program. The open source GCC Compiler is one of the best and also supports relatively fast for new C ++ standards. In many cases, however, commercial compilers like Microsoft’s are better in certain areas. Do not worry, you need to worry about that first as an expert.

First program

It’s best to create a simple “Hello World” program with the C ++ development environment. For this, we start a new project under File-> New Project and select a GCC Console project.

How to Compile C++ Programming in Raspberry Pi

Sample GCC Project

In the next step, we give the project a name and select a folder. Ready -> already we have our first test project, which we can create and execute with CTRL + F5 . Congratulations, your first CodeLite program on the Raspberry Pi is “hello world” on the console!

Execute Program

The build menu allows us to test our console program for development. The program is created as an executable file, either in the debug or release subfolder. Depending on which version you create. An adjustment can be found above the tree view of the project directory. But we can also run the finished program directly from the console. To do this, we navigate to the appropriate directory and execute it like a normal Linux program – unlike Windows, the compiler does not create a * .exe file. The created file is called like the project and has no file extension. Is but an executable file.

 

Conclusion

With the CodeLite C ++ development environment we can also comfortably program C ++ on the Raspberry Pi. I showed you how to install the program and use it with a first small project. In the following articles, I will show you more about C ++ programming.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

ten + 13 =