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