Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    R329 Tina Linux 编译 net-snmp 包失败

    编译和烧写问题专区
    1
    2
    1205
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fengshuo LV 3 last edited by

      如题。我在给 R329 开发板编译 Tina Linux 时用 menuconfig 选中了 net-snmp 包,导致 make 整个系统时报错:

       aarch64-openwrt-linux-gnu-gcc -I../include -I. -I../agent -I../agent/mibgroup -I../snmplib -I/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/target/usr/include -I/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/target/include -I/home/fengshuo/R329-Tina-jishu/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/usr/include -I/home/fengshuo/R329-Tina-jishu/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/include -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -Os -pipe -fno-caller-saves -fno-caller-saves -Wno-unused-result -Wformat -Werror=format-security -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -fpic -Ulinux -Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -c snmpd.c -o snmpd.o >/dev/null 2>&1
      /bin/sh ../libtool  --mode=link aarch64-openwrt-linux-gnu-gcc -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -Os -pipe -fno-caller-saves -fno-caller-saves -Wno-unused-result  -Wformat -Werror=format-security -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -fpic  -Ulinux -Dlinux=linux  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE   
      -o snmpd snmpd.lo  -L../snmplib/.libs -L../snmplib -L./.libs -L./helpers/.libs -L./helpers -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/target/usr/lib -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/target/lib -L/home/fengshuo/R329-Tina-jishu/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/usr/lib -L/home/fengshuo/R329-Tina-jishu/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/lib -znow -zrelro -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/toolchain/usr/lib -lm -lc libnetsnmpagent.la helpers/libnetsnmphelpers.la libnetsnmpmibs.la ../snmplib/libnetsnmp.la  -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lc -lcrypt    
      aarch64-openwrt-linux-gnu-gcc -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -Os -pipe -fno-caller-saves -fno-caller-saves -Wno-unused-result -Wformat -Werror=format-security -D_FORTIFY_SOURCE=1 -Wl,-z -Wl,now -Wl,-z -Wl,relro -fpic -Ulinux -Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -o snmpd .libs/snmpd.o -znow -zrelro -Wl,-E -fstack-protector-strong  -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent/.libs -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent/helpers/.libs -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/snmplib/.libs -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/snmplib -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent/helpers -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/target/usr/lib -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/target/lib -L/home/fengshuo/R329-Tina-jishu/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/usr/lib -L/home/fengshuo/R329-Tina-jishu/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/lib -L/home/fengshuo/R329-Tina-jishu/out/r329-evb5/staging_dir/toolchain/usr/lib ./.libs/libnetsnmpagent.so helpers/.libs/libnetsnmphelpers.so ./.libs/libnetsnmpmibs.so /home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent/helpers/.libs/libnetsnmphelpers.so /home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent/.libs/libnetsnmpagent.so /home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/snmplib/.libs/libnetsnmp.so ../snmplib/.libs/libnetsnmp.so -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lc -lcrypt    -Wl,--rpath -Wl,/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent/.libs -Wl,--rpath -Wl,/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent/helpers/.libs -Wl,--rpath -Wl,/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/snmplib/.libs
      /home/fengshuo/R329-Tina-jishu/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/6.4.1/../../../../aarch64-openwrt-linux-gnu/bin/ld: cannot find -lperl
      collect2: error: ld returned 1 exit status
      Makefile:394: recipe for target 'snmpd' failed
      make[4]: *** [snmpd] Error 1
      make[4]: Leaving directory '/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/agent'
      Makefile:511: recipe for target 'subdirs' failed
      make[3]: *** [subdirs] Error 1
      make[3]: Leaving directory '/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4'
      Makefile:254: recipe for target '/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/.built' failed
      make[2]: *** [/home/fengshuo/R329-Tina-jishu/out/r329-evb5/compile_dir/target/net-snmp-5.4.4/.built] Error 2
      make[2]: Leaving directory '/home/fengshuo/R329-Tina-jishu/package/network/net-snmp'
      package/Makefile:192: recipe for target 'package/network/net-snmp/install' failed
      make[1]: *** [package/network/net-snmp/install] Error 2
      make[1]: Leaving directory '/home/fengshuo/R329-Tina-jishu'
      /home/fengshuo/R329-Tina-jishu/build/toplevel.mk:304: recipe for target 'package/network/net-snmp/install' failed
      make: *** [package/network/net-snmp/install] Error 2
      

      提示找不到 perl 库。我试了:

      • 在用来编译的主机上安装 libperl-dev 包
      • 执行 make package/network/net-snmp/clean 清空生成的文件,然后执行 make package/network/net-snmp/install 单独重新编译这个包

      都没有用。请各位大佬帮忙看看是什么问题,谢谢。

      F 1 Reply Last reply Reply Quote Share 0
      • F
        fengshuo LV 3 @fengshuo last edited by

        @fengshuo 后续:

        我寻思着 ld: cannot find -lperl 的意思就是在 -L 指定的路径下找不到能链接的 libperl.so 或者 libperl.a 文件对吧,那我从 https://pkgs.org/download/libperl-dev 下载一个同版本 aarch64 架构的 libperl.a 补到 prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi-glibc/toolchain/lib 应该就行了吧。(整个 R329 SDK 不存在任何 libperl.so 或 libperl.a 文件而且 make menuconfig 也找不到叫“libperl”的选项,不得已才从网上下)

        不行。这回 ld 倒是找着了库,make 继续往下跑了几步之后又报错退出了:/usr/share/perl/5.26/Carp.pm panic: attempt to copy freed scalar

        网上一搜,这是 perl 的老 bug 了:https://rt.cpan.org/Public/Bug/Display.html?id=72467 照着这个帖子修改了 /usr/share/perl/5.26/Carp.pm 就不会再报错了。不清楚为什么交叉编译环境里的 perl 要引用系统的 perl 模块,不过毕竟 perl 是解释型语言,这样跨架构应该问题不大。

        之后再 make 又报错,说 U64 类型被定义了两遍。一遍在 out/r329-evb5/compile_dir/target/net-snmp-5.4.4/include/net-snmp/library/int64.h ,另一遍在 /usr/lib/x86_64-linux-gnu/perl/5.26/CORE/perl.h 。

        这个问题也是好几年前就有人给 net-snmp 团队报告过了:https://sourceforge.net/p/net-snmp/bugs/2794/ 高版本的 net-snmp 已修复,可惜SDK里包含的版本太旧。我参考修复了这个问题的 commit 31613e 照葫芦画瓢给它修了(就是把 U64 的 typedef 去掉,其他地方的 U64 换成 struct counter64 )。

        不知道是因为我这一通操作还是什么别的原因,后面 make 竟然用 /usr/bin/ld 去链接一堆很明显要走交叉编译的文件,然后告诉我它找不到各种各样的库...... 现在真的怀疑全志提供的 SDK 本来就有毛病。

        1 Reply Last reply Reply Quote Share 0
        • 1 / 1
        • First post
          Last post

        Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

        行为准则 | 用户协议 | 隐私权政策