Dart: build Dart SDK for x86 and ARM

Based on Building Dart, Building Dart SDK for ARM processors and Building Dart SDK for Raspberry Pi.

  • Ubuntu 16.04 LTS
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Dart SDK, master f6a2fb0050eeaf24706da66bdd73c2f3c9770f96
x86 toolchain

Pre-installed in Ubuntu (16.04 LTS).

ARM 32-bit toolchain

See Raspberry Pi: C++ cross-compiling .

ARM 64-bit toolchain
$ sudo apt-get install g++-aarch64-linux-gnu
Other build tools
$ sudo apt-get install g++ git make python
$ sudo apt-get install g++-multilib
Install Chromium depot_toops
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH="$PATH:$PWD/depot_tools"
Get the source
$ mkdir dart-sdk
$ cd dart-sdk
$ gclient config https://github.com/dart-lang/sdk.git
### Checkout HEAD
$ gclient sync
### Checkout a tag, e.g. 1.9.3
$ gclient sync --revision=1.9.3
Create (if missing) symbolic links

create_sdk build will fail if the following symbolic links are missing:

$ sudo ln -s /usr/include/x86_64-linux-gnu/asm/ /usr/include/asm
$ sudo ln -s /usr/include/x86_64-linux-gnu/bits/ /usr/include/bits
Build 64-bit x86
$ cd dart-sdk/sdk
$ ./tools/build.py --mode release --arch x64 create_sdk
Build 32-bit x86
$ cd dart-sdk/sdk
$ ./tools/build.py --mode release --arch ia32 create_sdk
Build for 32-bit ARM
$ cd dart-sdk/sdk
$ ./tools/build.py --mode release --arch arm create_sdk

The build fails (master #eb1839b):

g++ -MMD -MF x86/obj/runtime/bin/gen_snapshot_dart_io/eventhandler_linux.o.d -DDART_IO_SECURE_SOCKET_DISABLED -D_FORTIFY_SOURCE=2 -DNDEBUG -DTARGET_OS_LINUX -DTARGET_ARCH_ARM -DNDEBUG -DDART_USE_TCMALLOC -DDART_PRECOMPILER -I../../runtime -I../../third_party -I../.. -Ix86/gen -I../../third_party/tcmalloc/gperftools/src -I../../third_party/zlib -m32 -msse2 -mfpmath=sse -fno-exceptions -pthread -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-local-typedefs -O3 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Werror -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wvla -Wno-conversion-null -Woverloaded-virtual -g3 -ggdb3 -fno-rtti -fno-exceptions -O3 -fvisibility-inlines-hidden -fno-omit-frame-pointer -fno-rtti -fno-exceptions -c ../../runtime/bin/eventhandler_linux.cc -o x86/obj/runtime/bin/gen_snapshot_dart_io/eventhandler_linux.o
In file included from ../../runtime/vm/simulator_arm.h:19:0,
                 from ../../runtime/vm/simulator.h:15,
                 from ../../runtime/vm/atomic.h:11,
                 from ../../runtime/bin/reference_counting.h:8,
                 from ../../runtime/bin/socket.h:14,
                 from ../../runtime/bin/eventhandler_linux.cc:27:
../../runtime/vm/constants_arm.h:263:17: error: ‘dart::STMP’ defined but not used [-Werror=unused-variable]
 const SRegister STMP = EvenSRegisterOf(DTMP);
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.

This can be fixed by changing the dart-sdk/sdk/runtime/vm/constants_arm.h file, lines 262-263 from:

const DRegister DTMP = EvenDRegisterOf(QTMP);  
const SRegister STMP = EvenSRegisterOf(DTMP);


const DRegister DTMP __attribute__((unused)) = EvenDRegisterOf(QTMP);  
const SRegister STMP __attribute__((unused)) = EvenSRegisterOf(DTMP);

Raspberry Pi note: This procedure will produce a useful Dart VM – the dart and pub utilities.

Pre-built 32-bit ARM Dart SDK image
$ wget http://share.geomodule.com/dart-sdk-f6a2fb0050eeaf24706da66bdd73c2f3c9770f96.tar.gz
Build for 64-bit ARM
$ cd dart-sdk/sdk
./tools/build.py --mode release --arch arm64 create_sd
Install Dart SDK on Raspberry Pi

Make sure you have correct version of the GLIBCXX library, see here:


# On your build host host
$ cd dart-sdk
$ scp -r sdk/out/ReleaseXARM/dart-sdk pi@192.168.0.xxx:~/dart-sdk
# On Raspberry Pi
# Add the following line at the end of .bashrc
# export PATH=${PATH}:/home/pi/dart-sdk/bin
$ dart --version
Dart VM version: 1.24.0-edge.eb1839b8fd453b6c0c93376346743fa96db48440 (Sun Apr 16 18:04:59 2017) on "linux_arm"
$ pub --version
Pub 1.25.0-edge.511963d71509de50ac577ac22f3bac8d33c17e34

Git: links, cheatsheets, tutorials, etc…

setup git credentials store
$ git config credential.helper store
$ git config credential.helper store --file=github
merge and rebase

Atlassian Merge vs Rebase tutorial.

Rename local and remote branch

Taken from here.

### Rename local branch
$ git branch -m new-name
### Rename local branch if you are on a different branch
$ git branch -m old-name new-name
# Remove old remote and push new local branch
$ git push origin :old-name new-name
### Reset upstream branch for thew name, switch to the new local
$ git push origin -u new-name
### Remote
$ git push --delete <remote_name> <branch_name>
### Or
$ git branch -rd <branch_name>
### Local
$ git branch -d <branch_name>
### Squash merge
$ git checkout develop
$ git merge --squash feature/branch
### Revert to a specific commit
$ git checkout -f COMMITID -- .
$ git commit -a

### Revert a specific commit
$ git revert --no-commit COMMITID
git flow

Nice git flow cheatsheet.

git stash

Good tutorial from Atlassian.

git submodules

Good tutorial from Jon Cairns.

Export existing git project to Github/Bitbucket

More details see on How can I export the project in Eclipse to a GitHub repository:

# github
$ git remote add origin git@github.com:<username>/<reponame>.git
# bitbucket
$ git remote add origin https://<username>@bitbucket.org/<username>/<reponame>.git
$ git push -u origin master
Find branch point

Taken from stackoverflow:

$ git log --pretty=oneline master > 1
$ git log --pretty=oneline branch_A > 2
$ git rev-parse `diff 1 2 | tail -1 | cut -c 3-42`^

CMake: cross-compile GoogleTest

This post is about how to cross-compile GoogleTest in Eclipse.

  • Ubuntu 16.04 LTS
  • Eclipse Neon.3 Release 4.6.3
Install CMake
$ sudo apt-get install cmake
Checkout GoogleTest
$ git clone https://github.com/google/googletest.git
Configure ARM toolchain

How to install ARM toolchain see Raspberry Pi: C++ cross-compiling.

  • Create in the root of GoogleTest folder  toolchain-arm-linux-gnueabihf.cmake file with the following content:
# Target system

set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf)

# Cross compiler
SET(CMAKE_C_COMPILER   /usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)

# Search for programs in the build host directories

# Libraries and headers in the target directories
  • Configure CMake:
$ cmake -DCMAKE_TOOLCHAIN_FILE=./toolchain-arm-linux-gnueabihf.cmake
Create Eclipse project
$ cmake -G "Eclipse CDT4 - Unix Makefiles"

Import the project in Eclipse:

  • File > Import
  • Select:
    • General
    • Existing Project into Workspace
    • Next
  • Select project
    • Select root directory > Browse (to the GoogleTest folder)
    • Finish
Compile GoogleTest


Project > Build project

Check library type
$ readelf -a -W ./googlemock/gtest/libgtest.a | more

File: ./googlemock/gtest/libgtest.a(gtest-all.cc.o)
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          1328016 (bytes into file)
  Flags:                             0x5000000, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         10368
  Section header string table index: 10365

Raspberry Pi: C++ cross-compiling in Eclipse

Based on this GuruCoding page.

  • Ubuntu 16.04 LTS
  • Eclipse Neon.3 Release 4.6.3
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Raspberry Pi 3 Model B
ARM toolchain

See Raspberry Pi: cross-compiling blog.

Upgrade libstdc++ to 6.0.21 on Raspberry Pi

See Raspberry Pi: how to solve the “version `GLIBCXX_6.0.21′ not found” problem.

Install Eclipse IDE for C/C++ developers

Download, unpack from here.

Eclipse plugins


  • Help > Install new software > Work with: –All Available Sites–
  • Check “Mobile and Device Development”
  • Next > Accept the terms of the license agreement” > Finish
  • Restart Eclipse
Create project

In Eclipse:

  • File > New > C++ Project
  • C++ Project
    • Project name: helloworld
    • Project type: Hello World C++ Project
    • Toolchains: Cross GCC
    • Next
  • Basic Settings
    • Hello world greeting: Hello world!
    • Next
  • Select Configurations
    • Next
  • Cross GCC Command
    • Cross compiler prefix: arm-linux-gnueabihf-
    • Cross compiler path: /usr/bin
    • Finish
  • Project > Properties > C/C++ Build > Settings
    • Tool Settings > Cross Settings
      • Prefix: arm-linux-gnueabihf-
      • Path: /usr/bin
Enable C++ 11
  • Project > Properties > C/C++ Build > Settings
    • Configuration: Debug/Release
    • Tool Settings > Cross G++ Compiler > Dialect: ISO C+11 (-std=c++0x)
  • Project > Build All

Raspberry Pi: debugging with gdb, command line


This post is about how to debug Raspberry Pi software with gdb, command line. For gdb debugging in Eclipse see Raspberry Pi: gdb debugging in Eclipse.

In case you are interested how to debug Dart command line applications in IntelliJ – see Raspberry Pi: How to remote debug Dart command line applications in IntelliJ.


  • Ubuntu 16.04 LTS
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Raspberry Pi 3 Model B

Prepare/compile helloworld

See here.

Install gdb-multiarch on host

$ sudo apt-get install gdb-multiarch

Install gdbserver on Raspberry Pi

$ sudo apt-get install gdbserver


# On target, - debug host's ip address
$ gdbserver --multi
Listening on port 2345

# On host, - target ip address
$ gdb-multiarch
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target extended-remote
Remote debugging using
(gdb) set remote exec-file /home/pi/path/helloworld
(gdb) file /home/uname/path/helloworld
Reading symbols from /home/uname/path/helloworld...done.
(gdb) start
Temporary breakpoint 1 at 0x105f4: file src/helloworld.cpp, line 12.
Starting program: /home/uname/path/helloworld 
Temporary breakpoint 1, main () at src/helloworld.cpp:12
12    int main() {
(gdb) next
13        std::cout << "Hello World!" << std::endl;
(gdb) next
12    int main() {
(gdb) next
13        std::cout << "Hello World!" << std::endl;
(gdb) next
12    int main() {
(gdb) next
13        std::cout << "Hello World!" << std::endl;
(gdb) next
15    }

# On target
Remote debugging from host
Process /home/pi/path/helloworld created; pid = 2267
Hello World!


Raspberry Pi: C++ cross-compiling

  • Ubuntu 16.04 LTS
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Raspberry Pi 3 Model B
Install build tools

Check/install build-essential:

# Check if build-essential is installed
$ dpkg -s build-essntial
# Install build-essential if needed
$ sudo apt-get install build-essential
Install ARM toolchain
# ARM build tools
$ sudo apt-get install g++-arm-linux-gnueabihf
# Check installation
$ arm-linux-gnueabihf-g++ -v
Upgrade libstdc++ to 6.0.21 on Raspberry Pi

See Raspberry Pi: how to solve the “version `GLIBCXX_6.0.21′ not found” problem.

Create helloworld.cpp
#include <iostream>

int main() {
    std::cout << "Hello World!" << std::endl;
    return 0;
$ arm-linux-gnueabihf-g++ -O3 -g3 -Wall -fPIC -c -o helloworld.o helloworld.cpp
$ arm-linux-gnueabihf-g++ -o helloworld helloworld.o
Copy helloworld to Raspberry Pi
$ scp ./helloworld pi@192.168.0.xxx:/home/pi/path
Login into Raspberry Pi and run helloworld
$ ssh pi@192.168.0.xxx
# On Raspberry Pi
$ cd path
$ ./helloworld
Hello World!
g++-arm-linux-gnueabihf pakage detais
$ dpkg -s g++-arm-linux-gnueabihf
Package: g++-arm-linux-gnueabihf
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 11
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: gcc-defaults (1.150ubuntu1)
Version: 4:5.3.1-1ubuntu1
Depends: cpp-arm-linux-gnueabihf (>= 4:5.3.1-1ubuntu1), gcc-arm-linux-gnueabihf (>= 4:5.3.1-1ubuntu1), g++-5-arm-linux-gnueabihf (>= 5.3.1-3~)
Description: GNU C++ compiler for the armhf architecture
 This is the GNU C++ compiler, a fairly portable optimizing compiler for C++.
 This is a dependency package providing the default GNU C++ cross-compiler
 for the armhf architecture.
Original-Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>

Fuchsia OS: download, build and run


Supported build platforms

At the moment of writing two build platforms seems to be supported – Ubuntu and Mac OSx. This article focuses on Ubuntu.

Getting the source

How to install version control tools and checkout Fuchsia OS repositories is described on the Fuchsia Manifest page:

# Install tools
sudo apt-get install golang git-all build-essential curl
# Install jiri scripts
curl -s https://raw.githubusercontent.com/fuchsia-mirror/jiri/master/scripts/bootstrap_jiri | bash -s fuchsia
# Export path to jiri
cd fuchsia
export PATH=`pwd`/.jiri_root/bin:$PATH
# Import/update Fuchsia code
jiri import fuchsia https://fuchsia.googlesource.com/manifest
jiri update

Building Fuchsia

Build instructions can be found in the Fuchsia Repository:

# Setup build environment, amr64
source scripts/env.sh && envprompt && fset arm64
# Build

Built sysroot will be in:


and the boot image in:



cd fuchsia
git clone https://fuchsia.googlesource.com/third_party/qemu
cd qemu
./configure --target-list=arm-softmmu,aarch64-softmmu,x86_64-softmmu
make -j32
sudo make install

Run Fuchsia OS in QEMU

cd fuchsia/magenta
# Run aarch64 (optionally, with graphical consol - add -g)
./scripts/run-magenta-arm64 -x ../out/debug-aarch64/user.bootfs -m 2048 [-g]

Magenta on Raspberry PI

See Magenta on Raspberry Pi and Raspberry Pi: compile and run Magenta pages.