gpt4 book ai didi

c - 链接时出现 undefined reference 错误

转载 作者:行者123 更新时间:2023-11-30 16:16:29 24 4
gpt4 key购买 nike

Linux debian 32 位主机 PC。项目包含源代码和预构建的工具链,目标是ARM。当我尝试运行 make 来构建固件镜像时,几乎没有显示 undefined reference 错误,编译已停止。

... ...
if [ -f pppd/Makefile.cyt ]; then \
make -C pppd -f Makefile.cyt; \
else \
make -C pppd; \
fi
make[3]: Entering directory '/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/router/open_source/pkgs/pppd-2.4.1'
make -C pppd
make[4]: Entering directory '/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/router/open_source/pkgs/pppd-2.4.1/pppd'
/opt/emlix/pnx8181/bin/arm-linux-gnueabi-gcc -O2 -pipe -Wall -D__linux__=1 -DHAVE_PATHS_H -DHAVE_MMAP -I../include -I/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/router/open_source/include -DCHAPMS=1 -DMPPE=1 -DHAVE_CRYPT_H=1 -DUSE_CRYPT=1 -DPLUGIN -DCBCP_SUPPORT -Wl,-E -o pppd main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o eap.o chap-md5.o md4.o chap_ms.o sha1.o pppcrypt.o cbcp.o -ldl
auth.o: In function `check_passwd':
auth.c:(.text+0x1d00): undefined reference to `crypt'
auth.c:(.text+0x1e2c): undefined reference to `crypt'
pppcrypt.o: In function `DesDecrypt':
pppcrypt.c:(.text+0xfc): undefined reference to `encrypt'
pppcrypt.o: In function `DesEncrypt':
pppcrypt.c:(.text+0x158): undefined reference to `encrypt'
pppcrypt.o: In function `DesSetkey':
pppcrypt.c:(.text+0x230): undefined reference to `setkey'
collect2: ld returned 1 exit status
Makefile:226: recipe for target 'pppd' failed
make[4]: *** [pppd] Error 1
make[4]: Leaving directory '/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/router/open_source/pkgs/pppd-2.4.1/pppd'
Makefile.cyt:18: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/router/open_source/pkgs/pppd-2.4.1'
/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/Rules.mk:74: recipe for target '_subdir_pppd' failed
make[2]: *** [_subdir_pppd] Error 2
make[2]: Leaving directory '/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/router/open_source'
/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/Rules.mk:74: recipe for target '_subdir_open_source' failed
make[1]: *** [_subdir_open_source] Error 2
make[1]: Leaving directory '/home/roleyf/test/payton_1.4.1.SR1_gpl/payton/src/router'
Rules.mk:74: recipe for target '_subdir_router' failed
make: *** [_subdir_router] Error 2

Makefile对于“pppd”子目录。我认为这是链接错误,pppd 子模块中的 Makefile 由于某种原因找不到 libcrypt 库。该问题看起来像是间歇性错误,不规则、随机发生。有时编译允许我构建一个模块,但更多时候却不能。如何解决这个问题?

最佳答案

我解决了这个问题,问题是 Makefile 有代码(第 138 行),它在错误的位置寻找 libcrypt*.* 库,在我的构建 PC 上的/usr/lib 下(没有这些库)而不是tarball 中包含的工具链。我修改了这一行:

ifneq ($(wildcard /usr/lib/libcrypt*.*),)

ifneq ($(shell find ../.. -name libcrypt*.*),)

修改后,Makefile找到库并相应设置LIBS。

关于c - 链接时出现 undefined reference 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56570914/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com