Downloading and Compiling

This section is dedicated to explaining how to create more advanced applications. This code was created to be robot independent, and has been tested with several robot platforms. The way I achieved this is by using Object Oriented Programing. The code can be used immediately with a skid/steer robot built using the Lego Mindstorms EV3 kit.

The following instructions assume that the GNU Cross Compiler has been already installed and the process of compiling, and running programs in the EV3 brick is well understood.
The Robot Navigation software uses C++ shared libraries that are not available in the EV3 Linux operating system. Therefore the compiler must be instructed to statically link the libraries during compilation time. This method creates quite large executable files as the external functions have to be embedded in the executable. I have provided instructions for Linux and Windows users. The software is been updated regularly, so it is advisable to check for updates.
User that are already familiar with the following compilation method can alternatively choose to copy add and load the necessary dynamic libraries, which has the advantage of creating significantly shorter executable files.

Linux Instructions
Download all the program files from the Robonav Github repository using the following command:

git clone

The Makefile file must have the -static flag set in order to link the libraries statically.

CFLAGS = -g -Wall -static

Move to the directory containing the source code and compile the program using:


This command will create the executable main file. Copy this program and telnet (or ssh) into the EV3 Brick, then execute the program from the terminal window. The robot can be now controlled using the arrow keys directly from the computer terminal. There will be a lot of information presented on the screen, which shows the full state of the robot, sensors, and time. We will be using this information in future projects.
A video of the system in action can be found below.

Windows Instructions
Download the programs from the Robonav Github repository. This can be done using the “Download Zip” button available in the Web interface. By default it will be saved in the Downloads directory with the name Uncompress the zip file in a working directory. This will show several C++ files (extension .cpp).
It is advisable to compile the program using command line instructions first in order to verify that the compiler was correctly installed. Move to the directory containing the source code, and run the following instruction:

arm-none-linux-gnueabi-g++ *.cpp -o main

This instruction only verifies that the cross-compiler was installed. If the make program was installed properly as part of the Brickxcc IDE installation, you can use it to compile the code as follows:


Both solutions (compiler only or make) will create the same result, but the latter is more efficient as it only recompiles the programs that have been modified.
The main executable file can now be copied to and executed in the EV3 Brick using ssh for Windows tools.

The following tutorial shows how to use the Bricxcc-test-version IDE:
1.- Start Bricxcc:

2.- Open the main.cpp from the working directory.

3.- Open the Program Manager:

4.- Press the right button and select add files:

5.- Select all the files from the uncompressed working directory:

6.- The program manager should now contain all the C++ files.

7.- Before compiling, the C++ compiler must be instructed to statically link the libraries in the executable file. This is done by adding the -static directive under “how to link executable” available in the Edit/Preferences/Compiler/EV3 tab.

8.- Compile the program files [F5] and download the executable main in the EV3 Brick [F6]. Keep in mind that Bricxcc places by default the executable files in ram memory, under the /mnt/ramdisk/prjs directory.

9.- Telnet (or ssh) in the EV3 Brick. Locate the executable main file and run it. The robot can be now controlled using the arrow keys directly from the computer terminal. All of the information that shows up on the screen is the full state of the robot, sensors, and time. This information will be used in later projects.

Using Dynamic Libraries
The EV3 Linux kernel does not include the library (click on VIEW RAW to download) that Robot Navigation requires to operate. However this library can be copied into the micro-SD card and loaded as needed. Users that want to try this method can compile the program without addind the -static flag in the Makefile (Linux) or EV3 preferences (Bricxcc). The resulting executable file is significantly smaller. In order to use this option, the operating system must be instructed to add the path containing the library before running the main program as follows:

export LD_LIBRARY_PATH="/media/card/lib/:$LD_LIBRARY_PATH"

This instruction assumes that the file is copied inside the /media/card/lib/ directory. This needs to be called every time a new telnet or ssh session is created. Users that may want to use the EV3 menu can load the library and run the program with a single instruction:

export LD_LIBRARY_PATH="/media/card/lib/:$LD_LIBRARY_PATH" && ./main

The following video shows the full system in action:

Next >> Program Structure

9 Responses to Downloading and Compiling
  1. Charly says:

    Just tried it on Linux. Direct compile and scp from brick. It brilliantly works!

    Looks very interesting,

  2. Brian says:

    I am using Windows 7 64bit and BCC 3.3 (Build
    I get the following error:

    Compile/Download Failed
    Unknown GNU error code (-1)

    • admin says:

      I have only seen this error when I create a new program file and I try to compile it before saving it.

      • Konne says:

        Hi everybody,

        I get the same error:
        Compile/Download Failed
        Unknown GNU error code (-1)

        program is saved and I followed the instructions exactly. What can be the problem?

        • admin says:

          There is a good chance that the installation process was not done properly. I added a few more instructions that will help verifying that the cross-compiler and Linux-tools are properly installed. Please follow the additional instructions and let me know if you still have problems.

        • Psior says:

          Make sure you compile all the .cpp files, not just main.cpp. If they are all in the same directory this command should do the trick:

          arm-none-linux-gnueabi-g++ *.cpp -o robotnav

          • admin says:

            Yes, it is possible to compile the Robot Navigation code using that command. However using the “make” command has the advantage of compiling only the files that have been modified instead of all of them. The “make” command can also be used under Windows, provided that the Linux-tools were installed. This is a good option, if only the CrossCompiler is installed.

  3. Charly says:


    I want to add the Lego gyro into robotnav, but cant find any info related to it.

    Any hint were to begin?


    • admin says:

      You could use the Xg1300LGyro class as guideline. Your class will be inherited from EV3 as well, but instead of opening an I2C device, you need to open an RS232 device (http:/