Template:FAQ:Compiling 06b

From Net-SNMP Wiki
Jump to: navigation, search

Although this is definitely a Frequently Asked Question on the project mailing lists, it hasn't really been a Frequently Answered Question. The basic problem is that none of the core development team have much involvement or experience with embedded systems. And although we have repeatedly put out a plea for implementation reports and advice, this has not so far been particularly successful. So the first thing to say is that the following suggestions should be treated with a greater than usual level of suspicion.

The second thing to say is that compiling the Net-SNMP project for use on an embedded system typically means compiling the agent (rather than the trap receiver, or command-line tools). So that is what this entry will concentrate on.

There are three main aspects to consider:

  • how to compile the code,
  • what code to compile, and
  • how to install the resulting agent binary.

The Net-SNMP project uses the standard configure mechanism, so the usual cross-compilation options are available - in particular --host and --target. It is also possible to specify the compiler and linker to use (--with-cc and --with-ld), and any special flags to pass to them (--with-cflags and --with-ldflags). There shouldn't be anything particularly special about compiling the Net-SNMP code, so see the documentation for your target environment for more information.
(And please let us know if there is anything special that should be mentioned here!)

If the aim is simply to generate an SNMP agent to run on the target system, it's probably not necessary to compile the command-line tools or trap receiver. The configure option --disable-applications will omit these elements. See the previous entry for other potentially relevant useful options.

Unfortunately, the SNMP agent (and in particular, the code for individual MIB modules) is the most system-specific part of the Net-SNMP software. It may prove necessary to disable particular MIB modules if they do not compile successfully, or attempt to use the wrong system-specific APIs. This can be done using the configure option --with-out-mib-modules. Alternatively, the option --enable-mini-agent will omit all but the core MIB module code. Additional modules can then be added individually using --with-mib-modules.

Further information about how to deal with problems with individual MIB modules is reliant on suitable reports being forthcoming from the wider Net-SNMP community. The ball is in your court!

Finally, installing the agent binary is not simply a matter of copying the snmpd file onto the target system. The agent typically relies on a number of additional libraries (and possibly the presence of assorted MIB files, unless this has been explicitly omitted). It is normally necessary to run make install, before copying the installed framework to the target system.

If the install destination needs to be different to the eventual location on the target system, this can be handled using the configure options --prefix (for the target location) and --with-install-prefix (for the temporary install location). Alternatively, this can be handled as part of the install command:

      make install prefix={target location} INSTALL_PREFIX={temp location}

Alternatively, if the agent is compiled with static linking (and no MIB files), then it may be possible to simply copy the agent binary across to the target system. See the next entry for details.