1. configure配置
./configure \
--prefix=${INSTALL_DIR} \
--build=x86_64-linux \
--host=x86_64-poky-linux \
--enable-shared \
--with-default-snmp-version="3" \
--enable-ipv6 \
--with-openssl \
--enable-mfd-rewrites \
--with-logfile="/cfg/var/log/snmpd.log" \
--with-persistent-directory="/cfg/var/net-snmp" \
--disable-manuals \
--disable-ucd-snmp-compatibility \
--enable-as-needed \
--with-mib-modules="ucd-snmp/diskio" \
--without-kmem-usage \
ac_cv_header_linux_ethtool_h=no \
--disable-embedded-perl \
--with-openssl=${SDKTARGETSYSROOT}/usr/lib
2. make后报错
/usr/bin/ld: cannot find /lib/libm.so.6
/usr/bin/ld: cannot find /lib/libmvec.so.1
collect2: error: ld returned 1 exit status
Makefile:459: recipe for target '../blib/arch/auto/NetSNMP/default_store/default_store.so' failed
make[2]: *** [../blib/arch/auto/NetSNMP/default_store/default_store.so] Error 1
make[2]: Leaving directory '/net-snmp-5.7.3/perl/default_store'
Makefile:484: recipe for target 'subdirs' failed
make[1]: *** [subdirs] Error 2
make[1]: Leaving directory '/net-snmp-5.7.3/perl'
Makefile:295: recipe for target 'perlmodules' failed
make: *** [perlmodules] Error 1
3. 解决方案
x86_64-poky-linux-gcc -print-file-name=libm.so.6执行后结果为:libm.so.6,说明该工具链不能正确找到sysroot路径,需要手动显式指定。x86_64-poky-linux-gcc --sysroot=/intel-corei7-64/v2.0.3/sysroots/corei7-64-poky-linux/ -print-file-name=libm.so.6执行后结果为:/intel-corei7-64/v2.0.3/sysroots/corei7-64-poky-linux/lib/../lib/libm.so.6,说明工具链能够正常工作了。
对于make后找不到libm.so.6和libmvec.so.1的情况,只需找到对应Makefile,对应的地方添加--sysroot=/intel-corei7-64/v2.0.3/sysroots/corei7-64-poky-linux/即可。