For compiling and running the HelloWorld.cpp program, open the Terminal window. Inside the Terminal window, type ls and press Enter. You will now see a list of all the folder names present inside your RPi:
The HelloWorld.cpp is stored inside the Cprograms folder. To open the Cprograms folders, type cd (change directory) followed by the folder name, and press Enter:
cd Cprograms
The output of the previous command can be seen as follows:
Next, to view the content of the Cprograms folder, we will type ls again:
Inside the Cprograms folder, there is a Data folder and a couple of .cpp programs. The program in which we're interested is the HelloWorld.cpp program, as we want to compile and build this program. To do this, type the following command and press Enter:
gcc -o HelloWorld -lncurses HelloWorld.cpp
The following screenshot shows that the compilation was done successfully:
For compiling any code that uses the ncurses library, the code is as follows:
gcc -o Programname -lncurses Programname.cpp
After this, type ./HelloWorld and press Enter to run the code:
After you press Enter, the entire Terminal window will be cleared:
Next, press the h or H key, and the Hello World text will be printed in the Terminal window. To exit the Terminal window, press any key:
Now that we've created a simple HelloWorld program, and tested that the ncurses libraries work inside the Terminal window, let's write a program to control the LEDs and the buzzer.