gpt4 book ai didi

c - musl-gcc : undefined reference to __memcpy_chk

转载 作者:太空狗 更新时间:2023-10-29 15:00:03 36 4
gpt4 key购买 nike

我需要针对 musl-libc 编译一个 C 程序,以使其在嵌入式设备上运行。但是,我无法编译该程序。源取决于我传递给链接器的几个库:

/usr/local/musl/bin/musl-gcc app.c -o app -I../lib -lzlog -lfilter

这是我得到的输出:

/usr/local/musl/lib/libzlog.a(category.o): In function `strcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__memcpy_chk'
/usr/local/musl/lib/libzlog.a(conf.o): In function `strcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__strcpy_chk'
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__strcpy_chk'
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__strcpy_chk'
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__strcpy_chk'
/usr/local/musl/lib/libzlog.a(event.o): In function `sprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33: undefined reference to `__sprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33: undefined reference to `__sprintf_chk'
/usr/local/musl/lib/libzlog.a(format.o): In function `memcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:53: undefined reference to `__memcpy_chk'
/usr/local/musl/lib/libzlog.a(record.o): In function `strcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__memcpy_chk'
/usr/local/musl/lib/libzlog.a(rotater.o): In function `snprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64: undefined reference to `__snprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64: undefined reference to `__snprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64: undefined reference to `__snprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64: undefined reference to `__snprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64: undefined reference to `__snprintf_chk'
/usr/local/musl/lib/libzlog.a(rule.o): In function `syslog':
/usr/include/x86_64-linux-gnu/bits/syslog.h:31: undefined reference to `__syslog_chk'
/usr/local/musl/lib/libzlog.a(rule.o): In function `strcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__strcpy_chk'
/usr/local/musl/lib/libzlog.a(rule.o): In function `memcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:53: undefined reference to `__memcpy_chk'
/usr/local/musl/lib/libzlog.a(spec.o): In function `sprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33: undefined reference to `__sprintf_chk'
/usr/local/musl/lib/libzlog.a(zc_profile.o): In function `vfprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:127: undefined reference to `__vfprintf_chk'
/usr/local/musl/lib/libzlog.a(zc_profile.o): In function `fprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:97: undefined reference to `__fprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:97: undefined reference to `__fprintf_chk'
/usr/local/musl/lib/libzlog.a(zc_util.o): In function `snprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64: undefined reference to `__snprintf_chk'
/usr/local/musl/lib/libzlog.a(buf.o): In function `strcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:110: undefined reference to `__memcpy_chk'
/usr/local/musl/lib/libzlog.a(buf.o): In function `vsnprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:77: undefined reference to `__vsnprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:77: undefined reference to `__vsnprintf_chk'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:77: undefined reference to `__vsnprintf_chk'
collect2: error: ld returned 1 exit status

与 gcc 相同的命令工作正常。musl中没有实现这些功能吗?

最佳答案

您问题中的包含路径都是 glibc 文件,因此看起来您尝试链接的库是使用 glibc 构建的。这有时可以工作,但有局限性。在您的情况下,它是使用 _FORTIFY_SOURCE 的 glibc 版本构建的,它使用 glibc 中目前在 musl 中不可用的符号(通常在 musl 上使用的 _FORTIFY_SOURCE 实现工作方式不同).长期以来,这项工作一直在长期议程上,但不是优先事项;如果可以,最好针对 musl 重建库。

关于c - musl-gcc : undefined reference to __memcpy_chk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55246192/

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