Netbeans on the Pi

I was finally able to get the RF Outlets to respond to codesend on the Raspberry Pi, I celebrated for a few days with Pizza! Before I start planning my project, I took a look at Tim’s code again and realised I didn’t really like his style. To me, Tim’s code is a mixture of C and C++ code. I know it works but I’d rather use string instead of char * and cout instead of printf. I’ve decided to clean it up for myself and immediately set out to look for an IDE that would work on the Raspberry Pi. My default C++ IDE is Dev C++ while my all purpose IDE is Netbeans. Dev C++ seems to be a windows only program so my all purpose IDE might suffice. However, considering the processing power of the Pi, I was under the impression that Netbean’s requirements may be above what the Pi can offer. How silly of me!

Before coming to my senses.

I started looking for a new IDE to use for C++ coding on the Raspberry Pi and who better to ask than google? A quick search with the query “C++ IDEs on Raspberry Pi” yields dozens of IDEs. Some people mention Pico/Pine/Nano and some mentioned Vi. These suggestions makes me angry as these are editors and not IDEs. They are great to use as a quick editor or if you really want to suffer while coding. I had to use Pico to code C, C++, and even some Java programs while I was still an undergrad and I do not want to relive those days. Not to mention that it is much easier to explore other people’s code in an IDE as oppose to an editor. With all the search capabilities and code highlighting, IDEs make the task of programming easier.

From the list of IDEs presented to me by google, one caught my eye simply with its name. It is called Code::Blocks. Installation is actually pretty easy on the Pi all I have to do is run a few commands.

sudo apt-get update
sudo apt-get upgrade

These commands would ensure your Pi is updated.

Next simply run the following line

sudo apt-get install codeblocks

This would install Code::blocks on your Raspberry Pi.

Annoying discoveries

Code::Blocks is great! I have to load in the cpp files, edit them and some quick adjustments from my default keys to start coding back to my normal speed. If RCSwitch.cpp is open along with codesend.cpp or RFSniffer.cpp, I can get the IDE to take me directly to implementations of the methods within RCSwitch.cpp directly. However, I didn’t spend too much time on this IDE to learn more than the basics. The reason is, for some unknown reason, in the middle of editing a file, the IDE just crashed on me without notices. I had to retrace what I was doing and which file I was working on prior to the crash. To make matters worst, I started pressing ctrl+s to save my file every time I finish typing a line of code and this crash actually got me to derail a few trains of thoughts.

When I googled the cause of this to see if I can fix it, it seems one of the packages used by the application is not yet stable in the Raspbian world and there were suggestions to compile the program from source. I kind of gave up on Code::Blocks at this point as one of the articles I read mentioned that Netbeans would work on a Raspberry Pi 2 and up. Since I got a 3 B+, it is most likely that my experience with Netbeans on Raspbian would be decent. So I went ahead and removed Code::Blocks by issuing the following command.

sudo apt-get remove codeblocks

And I began my Netbeans installation search. My thoughts are, if Netbeans is not usable, I shall come back to Code::Blocks and recompile it from source if needed.

Netbeans!

From a post I came upon on the internet, Raspbian came with a Java VM. I quickly verify that it is there by opening a console and running the following two commands.

java -version
javac -version

To my surprise, Java 1.8 is fully installed. As Netbeans at its core is a Java application, it should be able to run without too much hassle. All I have to worry about is if the memory and processing power of the Pi would be sufficient for the current edition of Netbeans. To be honest, I was using Netbeans on a 450 Mhz CPU with RAM that was measured in Mb back in the old days. However, that was a very old version of Netbeans and the demand on the processor and memory isn’t as high back in those days.

Installation of Netbeans was also a very interesting path, some people online was suggesting to install it via downloading fromĀ netbeans.org and manually unzip it to a folder. I’ve decided on a different approach to see if it works, using good old apt-get. My reason is that Raspbian is a specialised version of Debian and Debian is also the core for Ubuntu. As I am a user of both Debian and Ubuntu, I guess that the following command would work.

sudo apt-get install netbeans

And it did. After downloading close to 600 mb of files from the repositories, Netbeans is available as an application on my Desktop in Raspbian and it is Netbeans 8!

Hooking up C++ with Netbeans

Since Netbeans is installed as a Java IDE, it doesn’t have the ‘full’ package that I usually download. In order to get C++ to work with Netbeans, the first thing I did was add the plugin for C++ development using the following steps.

(The following screenshots are taken from the Windows version of Netbeans 8.2, the look and feel is very similar on the Raspberry Pi version as that is the advantage of Java!)

Click on Tools > Plugins to launch the Plugins window

Click on the settings tab to ensure Certified Plugins and Netbeans Distribution are checked. For an unknown reason, my install of Netbeans on the Raspbian had these unchecked upon first load.

Next click on Available Plugins tab and search for C++

Check the C/C++ plugin and click install at the bottom of the window.

Once installed, click on the Installed tab and find the C/C++ module.

Check it and click on the Activate button at the bottom of the Window.

A new installer will appear, simply follow the on screen instructions to finish activation.

Close the plugins manager when the activation finishes.

At this point, if I create a new project, I will see C/C++ in the categories list in the New Project window.

For Tim’s code, I chose the C/C++ Project with Existing Sources so I can quickly import his code.

Hooking up g++ with Netbeans.

Next, click on Tools > Options

In the options window, look for the C/C++ option and click on it.

From my experience, simply clicking on add would have the GNU G++ added if it is not already picked up by Netbeans, on my windows side, as I don’t have g++ installed on this system, it doesn’t pick up.

Ensure the Make command, C++ compiler, and C compiler are present.

When this is done, simply click OK.

Mission Accomplished!

Leave a Reply

Your email address will not be published. Required fields are marked *