- EV3:
mkdir build
cd build
cmake .. -DEV3DEV_PLATFORM=EV3
make
- BrickPi:
mkdir build
cd build
cmake .. -DEV3DEV_PLATFORM=RPI
make
You have several options for compiling.
You can use a cross-compiling toolchain to create ARM compatible code. Note: You need a Linux toolchain, not a "bare-metal" toolchain. If it does not have "linux" in the name, it probably won't work.
Pros: Fastest option. Works on Windows and Mac without a virtual machine.
Cons: Only includes standard libraries - no Debian -dev packages.
MentorGraphics toolchain (formerly known as CodeSourcery).
Windows 10 supports the Windows Subsystem for Linux which allows us to install and execute the entire compiler toolchain. The steps required to compile native-mode EV3 applications on Windows 10 is as follows:
-
Be sure that your Windows 10 installation has Windows Subsystem for Linux installed. To install it, go to Control Panel --> Programs and Features --> Turn Windows Feature On/Off and check the box next to Windows Subsystem for Linux (Beta).
-
Fire up the bash shell by pressing Start Key, type
bashand pressEnter. This will open up Bash on Ubuntu on Windows. -
Install the ARM compiler by typing
sudo apt-get install arm-linux-gnueabi-gcc. -
Use
git cloneto clone this repository to the directory of your choice, e.g.,
git clone https://github.com/ddemidov/ev3dev-lang-cpp.gitwill clone the repo into a directory called /ev3dev-lang-cpp.git.
- You need to make some changes to the top-level
CMakeLists.txtfile. First, go into the directory
cd ev3dev-lang-cppNow, edit the CMakeLists.txt file with a text editor of your choice, e.g.,
vi CMakeLists.txtJust after the project(...) declaration, set the C/C++ compilers by adding the following lines:
set(CMAKE_CC_COMPILER "arm-linux-gnueabi-gcc")
set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++")Alternatively, you can set these environment variables during compilation (explained later).
- Now compile your programs and the generated binaries will be ready for EV3. This assumes that you have build tools such as
makeandcmakeinstalled - if not, install them withsudo apt-get install build-essential(for make) andsudo apt-get install cmakefor cmake. You can then perform compilation by invoking the following commands:
mkdir build && cd build
cmake .. -DEV3DEV_PLATFORM=EV3
makeIf you did not set the variables in the CMakeLists.txt file, use the following commands instead:
mkdir build && cd build
CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-g++ cmake ..
make- The
builddirectory will now contain folders with binary files ready to be executed on the EV3 brick. The easiest way to copy files is to use a program that supports SFTP, such as Filezilla. Remember that, by default, the username of the host system isrobotand password ismaker. The location of the path where the files are kept on disk is likely the following:
c:\users\<YOUR USERNAME>\appdata\local\lxss\home\<YOUR USERNAME>\ev3dev-lang-cpp\build\
- Be sure to
chmod u+x myprogramfor every copied program before running the program, otherwise you'll get anAccess Deniedin SSH or some really weird error if executing from the brick.
Brickstrap uses QEMU to create a virtual environment (not exactly a virtual machine) that can run the same ARM compatible code on a different type of computer.
Pros: Faster than running on the EV3 itself. Can install all Debian -dev
packages using apt-get.
Cons: Slower than cross-compiler. Requires Linux (Ubuntu).
See this page for instructions.
It is possible to compile programs on the EV3 brick itself.
Pros: Easy to setup.
Cons: Really slow.
Just run sudo apt-get install build-essential on the EV3 and you will have
everything you need.