2008年12月29日星期一

cross compile net snmp for mips(转自boeder)

cross compile net snmp for mips

By: Bian Jiang (borderj@gmail.com)
From: http://www.b0rder.com
Date: 2008.11.17

I'm trying to cross-compile NetSNMP 5.4.2 for running on an embedded system(mips).

由于我使用的CPU是little endian 交叉编译工具是 mipsel-linux

如果你用的是Big endian,交叉编译用具就可能是 mips-linux

1. 设置环境变量::

TOOLCHAIN=mipsel-linux-
CC=${TOOLCHAIN}gcc
CPP=${TOOLCHAIN}cpp
AR=${TOOLCHAIN}ar
STRIP=${TOOLCHAIN}strip
RANLIB=${TOOLCHAIN}ranlib
LD=${TOOLCHAIN}ld

2. 编译安装::

../net-snmp-5.4.2.1/configure --build=i686-linux --host=mipsel-linux --target=mipsel-linux --with-transports="UDP" --prefix=/opt/rootfs/snmp --with-endianness=little --with-persistent-directory=/var/net-snmp/ --with-default-snmp-version="2" --enable-mini-agent --without-kmem-usage --disable-debugging --disable-embedded-perl --without-perl-modules

make
make install

PS:
1. 如果你采用的是 Big endian, --with-endianness=little 应该改为 --with-endianness=big
2. 如果不想对openssl 的支持,用 --without-openssl

3. 测试::

border@ubuntu:/opt/rootfs/snmp/sbin$ pwd
/opt/rootfs/snmp/sbin
border@ubuntu:/opt/rootfs/snmp/sbin$ file snmpd
snmpd: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
border@ubuntu:/opt/rootfs/snmp/sbin$ file snmptrapd
snmptrapd: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped


参考:
1. http://fixunix.com/snmp/175765-multiple-warning-cross-compiling-net-snmp-mips-linux.html
2. http://mhonarc.axis.se/dev-etrax/msg09220.html

--Bian Jiang

--EOF--

没有评论:

发表评论