Skip to content

Build and Development Environment

rmadsen edited this page Sep 8, 2014 · 11 revisions

Building and Developing an Agent

Introduction

EOS SDK lets you develop agents on any 32-bit Linux environments, making it easy to compile and test new programs. This is because the SDK is simply a collection of C++ header files. On a real switch or vEOS instance, the SDK, these headers are contained in the library libeos.so, provided by the EosSdk.i686.rpm extension. However, in your development environment, these headers are backed by stubbed-out functionality, free from any EOS-specific dependencies. Your agent builds against this stubbed-out library and produces a binary executable that, when copied to the switch, dynamically links against the full libeos.so implementation.

This GitHub repository contains the entirety of the headers, stub implementation and examples. To develop against a specific version of the SDK, you can view and download a tarball from the releases page. We welcome improvements to stubs functionality, along enhancements to header comments and examples via pull requests. You can submit bug reports and suggestions through GitHub's issue tracker.

Set up

In order to compile C++ programs, you will need a 32-bit Linux system that has the following software installed:

Component Minimum Version
g++ 4.5.1
glibc 2.13 (libc version 6)
automake 1.14 (minimum version supported)
autoconf 2.66
m4 1.4.14

These build tools are included with many distributions, including Ubuntu 12.04, Fedora Core 14, and Fedora Core 18. On Ubuntu systems, the build tools are included with g++-multilib, while Fedora systems use libraries from the libgcc.i686, glibc-devel.i686, and libstdc++.i686 RPMs.

We recommend that users create a new (virtual) machine with one of these operating systems installed. Advanced users can cross-compile from a 64-bit environment to a 32-bit one, but instructions for that process are not included here.

Creating the stubs library

Once you have a system that meets the above requirements, download the stubs tarball with the same version as the release of the EosSdk.i686.rpm you plan on using. Then un-tar the package:

bash# tar xzf <SDK-stubs-version>.tar.gz

and run the build.sh script, which will configure the build system and make the stub version of libeos.so.

bash# cd <Newly-created-untarred-SDK-stubs-folder>
bash# ./build.sh
bash# sudo make install

The recommended set of flags when building your code can be found in build.sh's CFLAGS variable, and can be edited to include the compilation flags you prefer. Build output is saved in config.log, and will show relevant information in case of a compilation error.

Building the Python bindings

If you'd like to use Python, you can simply transfer your program to the switch, as the language does not require a compilation step. However, you may find it useful to generate the Python bindings locally so you can inspect the naming changes, run unit tests, or use pylint in your development environment. To do so, first install SWIG and then invoke build.sh with the --enable-python flag:

bash# ./build.sh --enable-python
bash# sudo make install
bash# python -m "import eossdk; print eossdk.version"
1.3.1

Building your agent

After creating the library, you can build your agent:

bash# g++ -std=gnu++0x -o MyAgent MyAgent.cpp -leos

You may pass additional compilation flags to g++.

At this point, you have a working C++ binary and a real EOS agent! This binary can be unit tested and even run locally. Currently the stubs only have minimal functionality, though, and are most useful when used in conjunction with a library that lets you externally trigger events, like GoogleMock. Once you copy to this executable to a switch with the extension installed, you can run the agent and have it link against the underlying SDK implementation.