Downloading and Compiling

This section is dedicated to explaining how to create more advanced applications using the unmodified LEGO EV3 firmware. The program can be used immediately with a skid/steer robot built using the Lego Mindstorms EV3 kit. After compiling the first test programs, readers will be able to remote control the robot using the keyboard as shown below.

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, Mac and Windows users. The software is been updated regularly, so it is advisable to check for updates.

Linux and Mac 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. The best way to do this is by using a git client (e.g. git for Windows). Alternatively, the programs can be downloaded 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).

Go to the directory containing the source code, and run the following instruction:


If the make program for Windows is not available, the program can still be compiled using the compiler only as follows.

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

Both solutions (make or compiler only) will create the same result, but using make 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.

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:/