Difference between revisions of "FAQ:Compiling 06"

From Net-SNMP Wiki
Jump to: navigation, search
 
(Latest FAQ revision - preparing for 5.5 release)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
= I'm getting an error "autoheader: not found" - what's wrong? =  
+
= How can I compile the project for use on an embedded system? =  
  
This usually appears when compiling the current development source
+
{{FAQ:Compiling_06b}}
version, obtained via CVS.  Unfortunately, the timestamps on some of
+
the configure files are such that make assumes (mistakenly) that the
+
configure script needs to be re-generated.
+
A similar problem may arise relating to <CODE>'autoconf'</CODE>.
+
 
+
In both cases, this can be corrected by running the command
+
<CODE>"make -k touchit"</CODE> before attempting to make the main package.
+
  
 
     [[FAQ:Compiling]]
 
     [[FAQ:Compiling]]
 
     {{FAQ:Compiling}}
 
     {{FAQ:Compiling}}

Latest revision as of 16:24, 19 July 2009

How can I compile the project for use on an embedded system?

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.

   FAQ:Compiling
   
  1. How do I control the environment used to compile the software?
  2. How do I control the environment used to compile the software under Windows?
  3. Why does the compilation complain about missing libraries?
  4. How can I reduce the memory footprint?
  5. How can I reduce the installation footprint or speed up compilation?
  6. How can I compile the project for use on an embedded system?
  7. How can I compile the project to use static linking?
  8. Why does 'make test' skip various tests?
  9. Why does 'make test' complain about a pid file?