How to Cross Compile AGENT++ a Step by Step Guide

Introduction

This tutorial will show how to cross compile the AGENT++ project on an GNU Linux embedded platform.

Overview of the project

The AGENT++ project consists in software packages dealing with the development of SNMP agents and the creation of SNMP MIBs. Some of these packages are written in C++, other in Java. Some of these packages can be freely used in both commercial and open-source products, and other require either an evaluation license to test the software during 15 days or a purchased one to use it indefinitely. In all cases, requesting support from the site is not free.

The list of the available packages is enumerated below:

SNMP++v2.8

Developed by Peter Mellquist (for HP), SNMP++v2.8 is a C++ API implementing SNMPv1/v2c protocol operations.

  • written in C++
  • no needed license
  • home page: http://www.agentpp.com/snmp_ppv2_8/snmp_ppv2_8.html
  • download page: http://www.agentpp.com/snmp_ppv2_8/download_snmp_ppv2/download_snmp_ppv2.html
  • package no more supported
  • no documentation available

SNMP++v3.2

Extends SNMP++v2.8 by adding SNMPv3 support and some bug fixes.

  • written in C++
  • no needed license
  • home page: http://www.agentpp.com/snmp_pp3_x/snmp_pp3_x.html
  • download page: http://www.agentpp.com/snmp_pp3_x/download_snmp_ppv3/download_snmp_ppv3.html
  • package still supported
  • documentation available at http://www.agentpp.com/doc_snmp++3.x/index.html

AGENT++

Extends the basic concepts of SNMP++ for the SNMP agent development.

  • written in C++
  • no needed license
  • home page: http://www.agentpp.com/agentpp3_5/agentpp3_5.html
  • download page: http://www.agentpp.com/agentpp3_5/download_agentpp/download_agentpp.html
  • package still supported
  • documentation available at http://www.agentpp.com/agentpp3_5/Documentation/documentation.html
  • there is also a mailing list, to subscribe go to http://lists.agentpp.org/mailman/listinfo/agentpp

AgentX++

Adds support for the AgentX (master and subagent) protocol to AGENT++ agents. Supports all AgentX features like contexts, index allocation, getbulk as well as seamless adding/dropping connections and sessions.

  • written in C++
  • free for non commercial use, needs to purchase a license for commercial use
  • home page: http://www.agentpp.com/agentx_pp1_4/agentx_pp1_4.html
  • download page: http://www.agentpp.com/agentx_pp1_4/download_agentx/download_agentx.html
  • documentation available at http://www.agentpp.com/agentx_pp1_4/agentx_doc/agentx_doc.html

AgenPro

A Java 2SE SMIv1/v2 MIB compiler application for the generation of C++ stubs for AGENT++ and Java stubs for the SNMP4J-Agent API. Since AgenPro has a fully customizable open source code generation backend, it can also be used to generate program code for Java or C with virtually any third party agent or management API.

  • evaluation license available for 15 days by providing an e-mail not coming from a free e-mail provider
  • home page: http://www.agentpp.com/agen/agen.html
  • download page: http://www.agentpp.com/agen/download/download.html

MIB Designer

A Java 2SE application for foolproof visual designing of SMIv2 MIBs (with optional conversion to SMIv1 for compatibility with legacy SNMP applications).

  • home page: http://www.mibdesigner.com

MIB Explorer

A Java 2SE SNMPv1/v2c/v3 MIB browser for effective and intuitive managing and monitoring of SNMP devices.

home page: http://www.mibexplorer.com

Download

So much packages! So much licenses! Our site is only interested in cross compiling open source projects for free use (even in commercial project). It is the reason why we will introduce the way to cross compile the latest SNMP++v3.2 and AGENT++ packages.

Downloading these two files can be done by typing the following commands:

(SNMP++v3.2 release 3.2.23 dated November 11th 2007)

wget http://www.agentpp.com/snmp++v3.2.23.tar.gz

(AGENT++ release 3.5.29 dated November 11th 2007)

wget http://www.agentpp.com/agent++v3.5.29.tar.gz

Note: to be compiled, agent++v3.5.29 needs snmp++v3.2.23 or later.

Environment Setup

The host machine will be a PC with a GNU Linux distribution installed.
The embedded platform might be constructed on top of one of the following architectures:

  • arm.
  • mips.
  • mipsel.
  • ppc.
  • sparc.

Prerequisites

To cross compile the AGENT++ packages, you need either a cross compiler, or an emulated Linux running on top of a virtualization software such as QEMU, matching your specific targeted platform.

In order to build yourself such a cross compiler, at crosstool page we introduced the way to build a C,C++ 4.1 GNU compiler for an ARM platform.

Also, hackers will be interested finding all the details to setup an ARM Debian system on their traditional Ubuntun distro following the indications quoted in this other arm-debian-on-ubuntu.

AGENT++ does not need specific dependencies.

The Cross compilation process

Option 1: Using a cross compiler

Assumptions
During the process, we will assume the cross toolchain is called xxx-yyy-linux-gnu, meaning that the gcc, g++, ar, ..., ld utilities are prefixed by xxx-yyy-linux-gnu. For example, for this toolchain the C compiler is called xxx-yyy-linux-gnu-gcc.

We will also assume that the bin, include, lib and libexec folders of the cross toolchain are accessible through the PATH variable environment in order to work with the compilers from any place in the file system.

Finally, we suppose it is intalled in the following folder: /opt/crosstool/gcc-4.1.2-glibc-2.3.2/xxx-yyy-linux-gnu.

Organization

As mentioned above:

SNMP++v3.2

  • The release being cross compiled is: 3.2.23
  • The tar.gz file will then be extracted under: /opt/external_packages/snmp++v3.2/3.2.23/source
  • The results of the compilation will be stored under: /opt/external_packages/snmp++v3.2/3.2.23/compiled/xxx-yyy-linux-gnu

The files resulting from the cross compilation are listed here:

   .:
   total 8
   drwxr-xr-x 3 root root 4096 2008-03-04 12:40 include
   drwxr-xr-x 2 root root 4096 2008-03-04 12:40 lib


./include: total 4 drwxr-xr-x 2 root root 4096 2008-03-04 12:40 snmp_pp
./include/snmp_pp: total 448 -rwxr-xr-x 1 root root 31829 2008-03-04 12:40 address.h -rwxr-xr-x 1 root root 17444 2008-03-04 12:40 asn1.h -rwxr-xr-x 1 root root 27955 2008-03-04 12:40 auth_priv.h -rwxr-xr-x 1 root root 7342 2008-03-04 12:40 collect1.h -rwxr-xr-x 1 root root 3390 2008-03-04 12:40 collect2.h -rwxr-xr-x 1 root root 3277 2008-03-04 12:40 collect.h -rwxr-xr-x 1 root root 7335 2008-03-04 12:40 config_snmp_pp.h -rwxr-xr-x 1 root root 4542 2008-03-04 12:40 counter.h -rwxr-xr-x 1 root root 10037 2008-03-04 12:40 ctr64.h -rwxr-xr-x 1 root root 5843 2008-03-04 12:40 eventlist.h -rwxr-xr-x 1 root root 3949 2008-03-04 12:40 eventlistholder.h -rwxr-xr-x 1 root root 4680 2008-03-04 12:40 gauge.h -rwxr-xr-x 1 root root 4887 2008-03-04 12:40 idea.h -rwxr-xr-x 1 root root 7105 2008-03-04 12:40 integer.h -rwxr-xr-x 1 root root 3830 2008-03-04 12:40 IPv6Utility.h -rwxr-xr-x 1 root root 12276 2008-03-04 12:40 log.h -rwxr-xr-x 1 root root 4010 2008-03-04 12:40 md5.h -rwxr-xr-x 1 root root 20921 2008-03-04 12:40 mp_v3.h -rwxr-xr-x 1 root root 5983 2008-03-04 12:40 msec.h -rwxr-xr-x 1 root root 7659 2008-03-04 12:40 msgqueue.h -rwxr-xr-x 1 root root 7425 2008-03-04 12:40 notifyqueue.h -rwxr-xr-x 1 root root 13535 2008-03-04 12:40 octet.h -rwxr-xr-x 1 root root 3805 2008-03-04 12:40 oid_def.h -rwxr-xr-x 1 root root 13681 2008-03-04 12:40 oid.h -rwxr-xr-x 1 root root 14220 2008-03-04 12:40 pdu.h -rwxr-xr-x 1 root root 2326 2008-03-04 12:40 reentrant.h -rwxr-xr-x 1 root root 2833 2008-03-04 12:40 sha.h -rwxr-xr-x 1 root root 7024 2008-03-04 12:40 smi.h -rwxr-xr-x 1 root root 6091 2008-03-04 12:40 smival.h -rwxr-xr-x 1 root root 12612 2008-03-04 12:40 snmperrs.h -rwxr-xr-x 1 root root 6324 2008-03-04 12:40 snmpmsg.h -rwxr-xr-x 1 root root 3495 2008-03-04 12:40 snmp_pp.h -rwxr-xr-x 1 root root 18067 2008-03-04 12:40 target.h -rwxr-xr-x 1 root root 4980 2008-03-04 12:40 timetick.h -rwxr-xr-x 1 root root 39746 2008-03-04 12:40 usm_v3.h -rwxr-xr-x 1 root root 21102 2008-03-04 12:40 uxsnmp.h -rwxr-xr-x 1 root root 8539 2008-03-04 12:40 v3.h -rwxr-xr-x 1 root root 12218 2008-03-04 12:40 vb.h
./lib: total 1920 -rwxr-xr-x 1 root root 1168484 2008-03-04 12:40 libsnmp++.a -rwxr-xr-x 1 root root 784430 2008-03-04 12:40 libsnmp++.so

AGENT++

  • The release being cross compiled is: 3.5.29
  • The tar.gz file will then be extracted under: /opt/external_packages/agent++/3.5.29/source
  • The results of the compilation will be stored under: /opt/external_packages/agent++/3.5.29/compiled/xxx-yyy-linux-gnu

The files resulting from the cross compilation are listed here:

   .:
   total 8
   drwxr-xr-x 3 root root 4096 2008-03-04 13:08 include
   drwxr-xr-x 2 root root 4096 2008-03-04 13:11 lib


./include: total 4 drwxr-xr-x 2 root root 4096 2008-03-04 13:11 agent_pp
./include/agent_pp: total 652 -rwxr-xr-x 1 root root 8450 2008-03-04 13:11 agent++.h -rwxr-xr-x 1 root root 15588 2008-03-04 13:11 agentpp_config_mib.h -rwxr-xr-x 1 root root 7380 2008-03-04 13:11 agentpp_simulation_mib.h -rwxr-xr-x 1 root root 8609 2008-03-04 13:11 avl_map.h -rwxr-xr-x 1 root root 4820 2008-03-04 13:11 entry.h -rwxr-xr-x 1 root root 30973 2008-03-04 13:11 List.h -rwxr-xr-x 1 root root 7163 2008-03-04 13:11 map.h -rwxr-xr-x 1 root root 8735 2008-03-04 13:11 mib_avl_map.h -rwxr-xr-x 1 root root 14596 2008-03-04 13:11 mib_complex_entry.h -rwxr-xr-x 1 root root 16944 2008-03-04 13:11 mib_context.h -rwxr-xr-x 1 root root 13469 2008-03-04 13:11 mib_entry.h -rwxr-xr-x 1 root root 97985 2008-03-04 13:11 mib.h -rwxr-xr-x 1 root root 7196 2008-03-04 13:11 mib_map.h -rwxr-xr-x 1 root root 7398 2008-03-04 13:11 mib_policy.h -rwxr-xr-x 1 root root 12555 2008-03-04 13:11 mib_proxy.h -rwxr-xr-x 1 root root 25432 2008-03-04 13:11 notification_log_mib.h -rwxr-xr-x 1 root root 11594 2008-03-04 13:11 notification_originator.h -rwxr-xr-x 1 root root 6559 2008-03-04 13:11 oidx_defs.h -rwxr-xr-x 1 root root 4860 2008-03-04 13:11 oidx_ptr.h -rwxr-xr-x 1 root root 6881 2008-03-04 13:11 proxy_forwarder.h -rwxr-xr-x 1 root root 28371 2008-03-04 13:11 request.h -rwxr-xr-x 1 root root 10322 2008-03-04 13:11 sim_mib.h -rwxr-xr-x 1 root root 12711 2008-03-04 13:11 snmp_community_mib.h -rwxr-xr-x 1 root root 9237 2008-03-04 13:11 snmp_counters.h -rwxr-xr-x 1 root root 15317 2008-03-04 13:11 snmp_group.h -rwxr-xr-x 1 root root 11636 2008-03-04 13:11 snmp_notification_mib.h -rwxr-xr-x 1 root root 22569 2008-03-04 13:11 snmp_pp_ext.h -rwxr-xr-x 1 root root 8307 2008-03-04 13:11 snmp_proxy_mib.h -rwxr-xr-x 1 root root 8010 2008-03-04 13:11 snmp_request.h -rwxr-xr-x 1 root root 15492 2008-03-04 13:11 snmp_target_mib.h -rwxr-xr-x 1 root root 44334 2008-03-04 13:11 snmp_textual_conventions.h -rwxr-xr-x 1 root root 8695 2008-03-04 13:11 system_group.h -rwxr-xr-x 1 root root 23277 2008-03-04 13:11 threads.h -rwxr-xr-x 1 root root 5817 2008-03-04 13:11 tools.h -rwxr-xr-x 1 root root 15107 2008-03-04 13:11 v3_mib.h -rwxr-xr-x 1 root root 8868 2008-03-04 13:11 vacm_class.h -rwxr-xr-x 1 root root 13489 2008-03-04 13:11 vacm.h -rwxr-xr-x 1 root root 5933 2008-03-04 13:11 WIN32DLL.h
./lib: total 15580 -rwxr-xr-x 1 root root 11283802 2008-03-04 13:11 libagent++.a -rwxr-xr-x 1 root root 4639153 2008-03-04 13:11 libagent++.so

Cross Compiling

SNMP++v3.2

Step 1

Install the SNMP++v3.2 software by untaring it in /opt/external_packages/snmp++v3.2/3.2.23/source folder and then cd to this directory.

Note:
All the directories and files listed below must be moved from the snmp++ folder
to its parent folder (/opt/external_packages/snmp++v3.2/3.2.23/source).

Directories and files:

     CHANGES.snmp++v3
     consoleExamples
     doc_config
     include
     lib
     QtExample
     readme.txt
     README.v3
     snmp_pp
     src
   

Step 2

cd to the src folder and type the following command in order to create a GNU/Linux makefile for your specific platform:

cp Makefile.linux Makefile.xxx.yyy

Now you need to edit this newly created Makefile in order to fit the compilation rules to your target environment and write the following changes:

CC = g++

becomes

CC = xxx-yyy-linux-gnu-g++
LD = ld

becomes

LD = xxx-yyy-linux-gnu-ld

Finally, insert the following line:

INSTPREFIX = /opt/external_packages/snmp++v3.2/3.2.23/compiled/xxx-yyy-linux-gnu
Step 3

Supporting SNMPv3 requires to work with additional cryptographic libraries, since we do not cover this in our tutorial, we will disable this option by making the following change in file ../include/snmp_pp/config_snmp_pp.h:

// #define _NO_SNMPv3

becomes

#define _NO_SNMPv3
Step 4

To compile and install the SNMP++v3.2 package, type successively make -f Makefile.xxx.yyy and make -f Makefile.xxx.yyy install.
You should find the directories and files listed above under /opt/external_packages/snmp++v3.2/3.2.23/compiled/xxx-yyy-linux-gnu.

AGENT++

Step 1

Install the AGENT++ software by untaring it in /opt/external_packages/agent++/3.5.29/source folder and then cd to this directory.

Note:
All the directories and files listed below must be moved from the agent++ folder
to its parent folder (/opt/external_packages/agent++/3.5.29/source).

Directories and files:

     agentgen
     CHANGES
     doc_config
     FAQ
     INSTALL
     LICENSE
     README
     src
     tools
     agent_pp
     doc
     examples
     include
     lib
     mibs
     README.SNMP++
     TODO
   

Step 2

cd to the src folder and type the following command in order to create a GNU/Linux makefile for your specific platform:

cp Makefile.linux Makefile.xxx.yyy

Now you need to edit this newly created Makefile in order to fit the compilation rules to your target environment and write the following changes:

CC = gcc

becomes

CC = xxx-yyy-linux-gnu-gcc
CPP = g++

becomes

CPP = xxx-yyy-linux-gnu-g++
GCC = gcc

becomes

GCC = xxx-yyy-linux-gnu-gcc
RANLIB = ranlib

becomes

RANLIB = xxx-yyy-linux-gnu-ranlib

Finally, insert the following line:

INSTPREFIX = /opt/external_packages/agent++/3.5.29/compiled/xxx-yyy-linux-gnu

Also, you'll need to edit the common.mk file and make the following changes:

SNMPPATH        = ../../snmp++/lib
SNMPINC         = ../../snmp++/include

becomes

SNMPPATH        = ../../../../snmp++v3.2/3.2.23/compiled/xxx-yyy-linux-gnu/lib
SNMPINC         = ../../../../snmp++v3.2/3.2.23/compiled/xxx-yyy-linux-gnu/include

Insert the following lines:

# agent++ lib headers
HEADERS         = $(wildcard $(INC)/agent_pp/*.h)

#
# Installation directories
#
ifndef INSTPREFIX
INSTPREFIX      = /usr/local
endif

INSTLIBPATH     = $(INSTPREFIX)/lib
INSTINCPATH     = $(INSTPREFIX)/include

install: all
        install -d $(DESTDIR)$(INSTLIBPATH)
        install -d $(DESTDIR)$(INSTINCPATH)/agent_pp/
        install $(LIBAGENTPLUS) $(DESTDIR)$(INSTLIBPATH)
ifneq ($(wildcard $(SHLIBAGENTPLUS)),)
        install $(SHLIBAGENTPLUS) $(DESTDIR)$(INSTLIBPATH)
endif
        install $(HEADERS) $(DESTDIR)$(INSTINCPATH)/agent_pp/
Step 3

To compile and install the AGENT++ package, type successively make -f Makefile.xxx.yyy and make -f Makefile.xxx.yyy install.
You should find the directories and files listed above under /opt/external_packages/agent++/3.5.29/compiled/xxx-yyy-linux-gnu.

Option 2: Using QEMU

This section is not yet available.

Download

  • arm-agent++-3.5.29-tar.gz
  • arm-snmp++v3.2-3.2.23-tar.gz

You may consult this section if you want to download the AGENT++ packages already cross compiled for your target platform if it is available. You can also contribute to expand the crosscompile.org community by uploading your own results in the case a given platform is not already supported.

Supported platforms

arm-unknown-linux-gnu


Written by David Sayada.

Edit History Last Modified March 10, 2008