net-snmp5.7.3 porting to the Arm-linux platform
This cross-compilation is performed under Ubuntu 15.04 64-bit systems.
Preparatory work
There are several preparations to complete before compiling the migration.
- 1 Download net-snmp 5.7.3 Source Package
- 2 Install the cross-compilation environment (ARM-LINUX-GNUEABI-GCC) using the command to
sudo apt-get install gcc-arm-linux-gnueabi
install.
Compiling the configuration
Unzip the NET-SNMP source package and enter the source package directory
unzip net-snmp-5.7.3.zip cd net-snmp-5.7.3/
There are those that can be used to ./configure --help
view the configuration options. There is no post, give directly.
Options |
Description |
–host=arm-linux |
Operating Platform |
–target=arm-linux |
Target platform |
–build=i686-linux |
Compiling the Platform |
–with-cc=arm-linux-gcc |
Cross-compilation tool |
–with-ar=arm-linux-ar |
Packaging tools to use |
–prefix=/usr/local/net-snmp |
installation directory |
–disable-shared |
Do not compile shared libraries |
–disable-scripts |
Do not install scripts such as MIB2C |
–with-endianness=little |
Specify the small-end mode |
-enable-mini-agent |
Minimize build agent |
--disable-deprecated |
Deprecated features are not compiled |
--without-logfile |
Specifies that SNMPD does not output a log file (you can use--with-logfile to specify the default log file location) |
--disable-minimalist |
Remove all non-basic code features |
–enable-debugging |
Open Debug Information |
--disable-testing-code |
Do not use test code (some code is not used) |
–with-openssl=/opt/hardhat |
OpenSSL library path (to support encryption, etc.) |
–disable-ipv6 |
Do not use IPV6 |
–disable-manuals |
Do not install the Manpage instructions page |
–disable-ucd-snmp-compatibility |
No compatible UCD-SNMP required |
–disable-snmptrapd-subagent |
No support for SNMPTRAPD's sub-agents |
–disable-embedded-perl |
The SNMP agent and SNMPTRAPD disable embedded Perl. Enabled by default |
–disable-applications |
Whether to turn off snmpget and other functions, choose according to your own needs |
--with-default-snmp-version= "3" |
Specifying the default protocol version |
--enable-as-needed |
Only links require libraries, not unnecessary libraries (if only other methods are not feasible, link libperl is for apps rather than NET-SNMP libraries.) ) |
Here is the configuration I used
Configure
./configure --host=arm-linux --target=arm-linux --build=i686-linux --with-cc=arm-linux-gnueabi-gcc-4.9 --with-ar=arm-linux-gnueabi-gcc-ar-4.9 --prefix=/usr/local/net-snmp --disable-shared --disable-scripts --with-endianness=little -enable-mini-agent --disable-ipv6 --disable-manuals --disable-ucd-snmp-compatibility --enable-as-needed
When configuring, you can specify an empty directory to use as the installation directory, for example /home/o/123
. Then make
you can install it after the success make install
. When porting to the arm
board, you can pack and copy the directory directly.
Configre successful output of the information
--------------------------------------------------------- Net-SNMP configuration summary:--------------------------------------------------------- SNMP Versions Supported: 1 2c 3 Building for: linux Net-SNMP Version: 5.7.3 Network transport support: Callback Unix Alias TCP UDP IPv4Base SocketBase TCPBase UDPIPv4Base UDPBase SNMPv3 Security Modules: usm Agent MIB code: default_modules => snmpv3mibs mibII/snmp_mib mibII/system_mib mibII/sysORTable mibII/vacm_vars mibII/vacm_conf MYSQL Trap Logging: unavailable Embedded Perl support: disabled SNMP Perl modules: building -- not embeddable SNMP Python modules: disabled Crypto support from: internal Authentication support: MD5 SHA1 Encryption support: DES AES Local DNSSEC validation: disabled---------------------------------------------------------
Compile
After the configuration is successful, compile with the make
command. After the compilation succeeds, the following two lines are output.
chmod a+x net-snmp-configtouch net-snmp-config-x
After the compilation is complete, you can go to the agent folder to see if the file is exported snmpd
.
[email protected]:~/snmp/net-snmp-5.7.3/agent$ ll snmpd-rwxrwxr-x 1 o o 3029820 9月 16 20:31 snmpd*[email protected]:~/snmp/net-snmp-5.7.3/agent$ file snmpdsnmpd: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=735ab05f48664e1af99c639e6519893be9413d2b, not stripped
Compress executable Files
After the compilation is ready to be used directly, but you can also compress to save space. Using arm-linux-gnueabi-strip
programs to compress
[email protected]:~/snmp/net-snmp-5.7.3/agent$ arm-linux-gnueabi-strip snmpd[email protected]:~/snmp/net-snmp-5.7.3/agent$ ll snmpd-rwxrwxr-x 1 o o 703836 9月 16 20:51 snmpd*
As you can see, the size of the executable file after compression 3MB
has been reduced from near to not 700KB
.
Install to target platform
Once the compilation is successful, it can be installed on the target platform. First copy the agent
files from the directory snmpd
to the target machine. Then create the configuration file on the target machine snmpd.conf
, how to configure, you can refer to the fifth part of Http://www.cnblogs.com/oloroso/p/4595123.html. Then you can start to try it.
sudo ./snmpd -c snmpd.conf –f –Le –d
Problems and workarounds not in Perl library
Compile when there is no Perl library problem, this problem is also good to solve, compile one is. But, without this necessity, trouble.
/usr/lib/gcc-cross/arm-linux-gnueabi/4.9/../../../../arm-linux-gnueabi/bin/ld: cannot find -lperlcollect2: error: ld returned 1 exit statusMakefile:484: recipe for target ‘libnetsnmpagent.la‘ failedmake[1]: *** [libnetsnmpagent.la] Error 1make[1]: Leaving directory ‘/home/o/snmp/net-snmp-5.7.3/agent‘Makefile:656: recipe for target ‘subdirs‘ failedmake: *** [subdirs] Error 1
The solution is really simple, add configure
a parameter to the previous configuration --disable-embedded-perl
, and then make
you can do it again.
"net-snmp5.7.3 Transplant to Arm-linux platform"