First steps for C++ programmers?

which are the first steps for C++ programmers?
In the installation guide there are only 2 sections ( C/C++ is still missing yet! ) :

Programming Options

Choose one of the languages below:



so for the first mounting:
just plug the BrickPi on to the Pi without any preparations?
extra voltage supplies required?

for a start with Raspbian (Jessie) already running:
(Raspbian installed by NOOBS: user pi, no password)
setup preferences in Linux config files (boot/config.txt? menu->Raspi configuration?) ?
(probably enable SPI, anything else?)
download and install Linux drivers?

for gcc/gpp:
download and install C API libraries :
sudo git clone…? sudo apt install… (.so, .a, .cpp, .c, .hpp., .h, folder <BrickPi>)?
where to copy .h, .hpp, .c, and .cpp files ( /usr/local/include? /usr/local/lib? manually create directories? ) to be accessable from anywhere (/home/pi/…? by #include <BrickPi.h> or anything?)
compile and build flags (-l..., -L..., -I...) ?
gcc 4.9 ok? -std=c11 needed?

for the BrickPi HAT:
how to check the current firmware?
how to update firmware (in case)?

anything else…
before you “hello brickpi world”?

could please someone kindly answer my questions?
I have now ordered my first Brickpi3 and I want to avoid making mistakes at the very first steps in order not to muddle up anything leading to consecutively unrepairable faults or damages!

You can follow the BrickPi3 Getting Started Guide to get the hardware and software set up (there’s also info in there regarding power requirements). On standard Raspbian (or Raspbian for Robots), you can follow the software installation instructions. The install script does all the necessary configuration (enable SPI, install the BrickPi3 python modules, etc.).

For C/C++ while we do now have drivers available, we don’t have a “getting started with C” tutorial. When you install the BrickPi3 software, the C++ drivers and examples are included (they get installed in the directory /home/pi/Dexter/BrickPi3/Software/C). For compiling, see the example compile command in the C examples. To compile the examples for testing, I just put the BrickPi3.h and BrickPi3.cpp files in the same directory as the program I was compiling (e.g. info.c).

To check the firmware version, you can either run the python example “” or you can compile and run the C program “info.c”.

You can update the firmware as described here.

do I actually really need to have Python libs + modules and all that?
( I finally never use Python at all …)

sudo git clone /home/pi/Dexter/BrickPi3

sudo bash /home/pi/Dexter/BrickPi3/Install/

So I thought I could probably skip all the entire part ?

You’re welcome to not follow the instructions, but I highly recommend that you run the install script. If you don’t want to run the install script, look through it and run all the necessary commands according to what you want. The Python modules are light, and unless you are really concerned with size, I don’t think you need to worry about them being installed.

ok, as it’s highly recommended then of course I finally did that.
I also eventually saw that some tools are helpful written as .py

for making the BrickPi *.h and *.cpp sources globaly available, would you agree to copy them just to

update: I did that and copied both files

into that folder
without having them additionally in the working dir, and everything compiled an run fine.

I am using the Geany IDE which is quite as handy and convenient as the former NXT BricxCC IDE,
compile/build preferences/settings:

g++ -Wall -c "%e" "%f"
g++ -Wall -o "%e" "%f"

make %e.o

sudo "./%e"

now you can do by pressing:
F8 (compile)
F9 (build)
F5 (run)

everythings runs smooth an perfect.

Share and enjoy!

As of BrickPi3 PR #67 BrickPi3.h and BrickPi3.cpp are now installed to /usr/local/include.

1 Like