User Tools

Site Tools


build_iotivity_with_ubuntu_build_machine

Build and run IoTivity projects using Ubuntu Build Machine

Setup

Before building sources for your os make sure to install needed tools. This guide works for Ubuntu 12.04 or newer.

Install build env

$ sudo apt-get install \
    build-essential git scons libtool autoconf \
    valgrind doxygen wget unzip

Install external libraries:

$ sudo apt-get install \
    libboost-dev libboost-program-options-dev libboost-thread-dev \
    uuid-dev libexpat1-dev libglib2.0-dev libsqlite3-dev libcurl4-gnutls-dev

Build

Next, you'll need to get the sources for IoTivity. Change directories to the top directory of iotivity source code. You'll be building with scons, and you should always run the 'scons' command in this directory.

Build release binaries:

$ scons

(Note: C++ sdk requires cereal. Please follow the instruction in the build message to install cereal.)

Build debug binaries:

$ scons RELEASE=false

Run unit tests :

$ scons TEST=1

Verbose :

$ scons VERBOSE=true

Help:

$ scons -h

Clear:

$ scons -c

Run the samples

 $ export LD_LIBRARY_PATH=<iotivity>/out/linux/x86_64/release 
  • Run the c++ samples in <iotivity>/out/linux/x86_64/release/resource/examples
  • Run the c samples in <iotivity>/out/linux/x86_64/release/resource/csdk/stack/samples/linux/SimpleClientServer

('<iotivity>' is the path to the 'iotivity' project. If your device is x86, arm, or arm64, please change 'x86_64' to the proper arch.)

How to build IoTivity projects

IoTivity includes a series of projects. You can find all these projects here:

  https://gerrit.iotivity.org/gerrit/#/admin/projects/

You can build the IoTivity project on Linux, Windows, or MAC OSX for various OS ( Linux, Tizen, Android, Arduino, Windows, MAC OSX, IOS …). The output of the build is in this directory:

<top directory of the project>/out/<target_os>/<target_arch>/<build_type>/

e.g.

iotivity/out/android/armeabi-v7a/release/.

This document uses the 'iotivity' project as an example; the way to build other projects is almost the same.

IoTivity project build tool scons

Scons is a cross-platform build tool, its usage is quite similar to GNU make. To build a project, you just require to run following command at the directory where a SConstruct file exists(SConstruct is the entrance of scons build, it's equivalent to Makefile of 'make') :

    $ scons [options] [target]

In additional, usually the scons build script of a project provides useful help information(include build options). To see the help information:

    $ scons [options] -h

Note: If no value is specified for an option, the default value will be used. The change of options value may impact the help information and the behavior of the building.

Generally, it's required to specify the target OS and target ARCH, that's to say tell Scons which OS and which ARCH you'd like build this project for. By default, the target OS and ARCH is the same as the host.

Some more options may be required, please care the 'error' notification when build. For help about how to set an option, please run:

   $ scons TARGET_OS=xxx TARGET_ARCH=yyy [XXX=zzz ...] -h

Prerequites

Scons

  Please refer to the following page to install scons:
    http://www.scons.org/doc/production/HTML/scons-user.html#chap-build-install
    (Note: on Windows, install Python 2.x before installing scons)

IDE/SDK Prerequites

To build for some OS (Android / Arduino / IOS …), an IDE/SDK may be required, please go to the relative page to download and install the required IDE/SDK.

Android:

To build for Android, Andorid NDK and SDK are required.

Android NDK: http://developer.android.com/tools/sdk/ndk/index.html
Android SDK: http://developer.android.com/sdk/index.html

(Note: as in some IoTivity projects, C++11 features are used, recommend Android NDK >= r10)

Arduino:

To build for Arduino, Arduino IDE is required.

Arduino IDE: http://arduino.cc/en/Main/Software
(Note: recommend install Arduino IDE >=1.5.7)

Arduino builds are dependent on latest Time library. Download it from here:

  http://www.pjrc.com/teensy/td_libs_Time.html

and extract to <arduino_ide_root>/libraries/

(Note: If you are using Arduino IDE 1.5.8 BETA on Windows, it may pop up some dll isn't found. please copy relative dll from the IDE directory to C:\Windows\SysWOW64. IDE 1.5.7 doesn't have this issue. Other version IDE isn't tested.)

Apple:

To build for Mac OSX or IOS, Xcode is required.

Xcode: https://developer.apple.com/xcode/downloads/

Java:

To build the Java code, JDK is required.

JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html

(If the project doesn't include Java code or you wouldn't like build the Java codes, this isn't required)

(Note: for convenience, suggest add the IDE/SDK path in environment variable, so you don't need to add it in command line each time. The build script will guide you to do that.)

External libraries

IoTivity project depends on some external libraries, such as boost, expat … During building, the existence of external library will be checked, if it doesn't exist, the build script will try to download, unpack and build the library or notify user to install it.

Downloading and unpacking may fail due to network problem or required unpacking tool isn't installed. An message will be displayed, please follow the message to skip it.

To Install Boost on Linux:

Download and install boost libraries by running the following command in your terminal window:

If using a debian based distro just type : $ sudo apt-get install libboost-all-dev

Resources :

https://packages.qa.debian.org/b/boost-defaults.html

https://launchpad.net/ubuntu/+source/boost-defaults

Build IoTivity project on Linux(Ubuntu)

Build IoTivity project for Linux

    $ cd <top directory of the project>
    $ sudo apt-get install libboost-dev libexpat1-dev libboost-thread-dev
    $ scons

Build IoTivity project for Android

    $ cd <top directory of the project>
    $ scons TARGET_OS=android TARGET_ARCH=xxx

(xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard. To see all of its allowed value, please execute command 'scons TARGET_OS=android -Q -h')

Build IoTivity project for Arduino

    $ cd <top directory of the project>
    $ scons TARGET_OS=arduino TARGET_ARCH=xxx BOARD=yyy

(xxx can be avr, arm; yyy is the name of the board, to get its allowed value run: scons TARGET_OS=arduino TARGET_ARCH=xxx -h. You may see a option 'CPU' in the output of above command line, that's due to some boards have different processors, to specify the processor, add 'CPU=zzz' in the command line. If no 'CPU' option exists, that means the board only support one kind of processor, it's unnecessary to specify it)

Build Iotivity project for Tizen

    $ cd <top directory of the project>
    $ gbs build -A xxx --packaging-dir tools/tizen/

(xxx can be i586 or armv7l, we provide the spec file required by gbs tool at toools/tizen directory. gbs is default build tool for Tizen platfrom, we can refer the following wiki to setup Tizen development environment: https://source.tizen.org/documentation/developer-guide/getting-started-guide)

Build IoTivity project on Android

Build IoTivity project for Android(It's the same as on Ubuntu)

    $ cd <top directory of the project>
    $ scons TARGET_OS=android TARGET_ARCH=xxx

(xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard …)

Build IoTivity project for Arduino(It's the same as on Ubuntu)

    $ cd <top directory of the project>
    $ scons TARGET_OS=arduino TARGET_ARCH=xxx BOARD=yyy

(xxx can be avr, arm; yyy is the name of the board, to get its allowed value run: scons TARGET_OS=arduino TARGET_ARCH=xxx -h. You may see a option 'CPU' in the output of above command line, that's due to some boards have different processor, to specify the processor, add 'CPU=zzz' in the command line. If no 'CPU' option exists, that means the board only support one kind of processor, it's unnecessary to specify it)

Note: Currently most IoTivity project doesn't support Windows, so you can't set TARGET_OS to 'windows' except the project support Windows.

That's to say if the project doesn't support Windows, run:

    $ scons TARGET_OS=windows ....

or run on Windows

    $ scons

may always fail.

Build IoTivity project on Mac OSX

Build IoTivity project for Mac OSX

    $ cd <top directory of the project>
    $ scons SYS_VERSION=yyy

(yyy is the OSX version, e.g. 10.10)

Build IoTivity project for Android(It's the same as on Ubuntu)

    $ cd <top directory of the project>
    $ scons TARGET_OS=android TARGET_ARCH=xxx

(xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard)

Build IoTivity project for IOS

    $ cd <top directory of the project>
    $ scons TARGET_OS=ios TARGET_ARCH=xxx SYS_VERSION=yyy

(xxx can be i386, x86_64, armv7, armv7s, arm64, yyy is IOS version, e.g. 8.3)

Note: 1) for convenience, a script (auto_build.sh) is provided to run possible build at once. Following is the usage:

To build:

   $ auto_build.sh <path-to-android-ndk>

To clean:

   $ auto_build.sh -c

2) For Arduino build, the Time library should >=1.3. The old can only be built with Arduino IDE 1.0.x

build_iotivity_with_ubuntu_build_machine.txt · Last modified: 2017/03/15 20:49 by Ben Lloyd Pearson