Up until now, we have looked at Python for building programs on the Raspberry Pi. Here, we’ll look at the top editors for writing C++ programs on the Raspberry Pi!
Good Ol’ Text Editor
Believe it or not, you do not need any special IDE or editor to make C++ programs on the Raspberry Pi. While such tools are invaluable when making programs - including features such as debugging and auto-completion - a simple text editor can be compiled natively on the Pi. This can be ideal in a number of situations where only a simple program is needed (no GUI) or an easy to use interface is desired (IDEs can be notoriously fiddly and bloated). When a C++ program is made in a text editor, it can be compiled via the command line:
gcc myprog.cpp ./myprog
The Geany IDE can be thought of as a more advanced text editor, including several useful features. First, if a program being written is given the correct file extension, such as .cpp or .py, it automatically recognizes the file type and applies the correct build settings. Compiling C++ programs using the Geany IDE is very easy and a simple “Hello World” program can be made in less than a minute. The IDE also contains a console output which shows build messages and statuses. It also has a symbols panel displaying the variables and functions of your program. Geany is incredibly fast and a very pleasant IDE to code in, especially for beginners. Of course, most advanced functions are not included, like debugging, which may be important in more complex programs.
Code::Blocks is a very powerful IDE for C++ and C programs. The IDE includes project management, debugging, compilation options, file management, auto-completion, and much more. Unlike text editors, Code Blocks has its own console, which is very helpful when testing programs, since Linux based operating systems have a habit of not running programs due to denied permissions. While the editor is bulky and complex at times, it is well worth the time and effort for the results.
Qt Creator is another IDE, similar to Code::Blocks, and it’s useful for making programs in a range of different languages. Qt Creator is mainly focused on creating Qt GUI based applications that include buttons, edit boxes, lists, and images. One of the main advantages behind QTCreator is the inclusion of a GUI editor. This allows for graphical creation in a similar way to Visual Studio. But QTCreator does have a disadvantage; it is not the easiest IDE to set up on the Raspberry Pi.
When writing your first C++ programs, it’s probably best to use an IDE such as Geany as it provides a lightweight and easy-to-use editor. Unlike text editors, Geany can run programs via the menu bar and rarely run into some instances where permissions are needed. When programs require multiple files and many classes, it becomes easier to use a more advanced IDE such as Code::Blocks.