Using C++ on Dietpi

disclaimer: I am new to coding and pi-ing, please be detailed in your answers!

I am working on a project and need to use code that is written in c++, but I know to convert it to Python would be fairly painful. I read that I would need to use a GCC compiler to allow dietpi to run c++, but I don’t know how to install that onto the dietpi. How would I go about doing that?

Have a look into dietpi-software and install Build Essential. Usually this should do it. To verify run

gcc --version

The compiler package is:

apt install g++

It pulls in the C++ standard library and development headers, as well as C compiler, standard library and headers, hence shouldn’t leave anything open. The command then is g++ as well.

Installed as well via Build-Essential in dietpi-software indeed, which adds make and automake (+autoconf) as well:

dietpi-software install 16
1 Like

Same symptoms for me, and this solution worked. Thanks!

See my previous post :wink:. The Bulld-Essential package has been removed, as it did not much more than installing g++ anyway, hence:

apt install g++

Generally, keep in mind that DietPi is build on top of Debian, hence you can install all the 60k APT packages form the Debian repository, like on any other Debian or Ubuntu system. So doing some search online for “Install C++ on Debian” will work for DietPi as well.

Often, you’ll see references to the build-essential APT package. Note that this does not only contain C++, but also some Dpkg headers and packaging tools, which one usually does not need, and make. I would not install such meta packages, but always the actual final package you, need, i.e. g++ if you need the C++ compiler, make if you need it, etc.