gpt4 book ai didi

glibc - libc 和 undefined symbol : stime

转载 作者:行者123 更新时间:2023-12-05 03:37:01 25 4
gpt4 key购买 nike

我有一个使用名为 FTDI 驱动程序库的 python 应用程序:

/usr/local/lib64/libftd2xx.so.1.4.22

当我使用 libc 2.27 运行应用程序时,它工作正常。

当针对 libc 2.32 运行它时,它失败并显示以下内容:

/usr/local/lib64/libftd2xx.so: undefined symbol: stime

在查看 libc 版本时,确实有一些与 libc 2.31 中的 stime 相关的内容,如下所述:https://lwn.net/Articles/811315/

它说:

"The obsolete function stime is no longer available to newly linkedbinaries, and its declaration has been removed from <time.h>."

我的理解是,只有“新代码”无法编译/链接此函数,但使用此函数的现有库应该仍然有效。

事实上,如果我在 2.27 和 2.32 中通过下面的粗略命令查找 stime 符号,我发现 stime 就在那里:

2.27

root@PPL23:~# nm --demangle --dynamic --defined-only --extern-only /lib/x86_64-linux-gnu/libc-2.27.so* | grep stime
00000000000d5ee0 T stime

2.32

localhost /tmp #  nm --demangle --dynamic --defined-only --extern-only /lib64/libc-2.32.so | grep stime
000000000012e490 T stime@GLIBC_2.2.5

为什么 libc 2.32 不能向后兼容现有的 FTDI 驱动程序?既然符号似乎在那里,即使是 2.32 版本也不应该这样吗?

最佳答案

根据手册页 stime(2)已弃用。

NOTE: This function is deprecated; use clock_settime(2) instead.

代替:

stime(100)

可以使用以下代码:

clock_settime(CLOCK_REALTIME, (struct timespec*){100,0})

如果出于某种原因你想使用 stime,你可以使用 SymbolVersioning 中提出的汇编技巧。

__asm__(".symver stime,stime@GLIBC_2.2.5");

关于glibc - libc 和 undefined symbol : stime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69482582/

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