2

我正在尝试在 Debian Linux lenny 下使用 timerfd_create 和 timerfd_settime。手册页说包括<sys/timerfd.h>. 此文件无法在我的系统上找到。根据 Debian 包搜索,唯一带有 timerfd.h 的包是 linux-headers-* 包。

我已经安装了包 linux-headers-2.6.26-1-amd64 和 linux-headers-2.6.26-1-common。我尝试包括 /lib/modules/2.6.26-1-amd64/build/include/linux/timerfd.h 文件(不包括<sys/timerfd.h>)。但后来我得到以下链接器错误:
slave.c:(.text+0x166): undefined reference to timerfd_ceate
slave.c:(.text+0x1e5): undefined reference totimerfd_settime

我的构建命令是 gcc -o slave slave.c -L../libs -lcan -lutils -lrt

can 和 utils 库是我自己的。他们都不使用或定义 timerfd_* 函数之一。我尝试了 -lrt 因为 timer_create 和 timer_settimer 需要它,即使它不在手册页中。带有 timer_create 和 timer_settimer 的测试程序可以正常工作并且符合预期。

我需要安装哪些数据包,需要链接到哪些库,以及使用 timerfd_create 和 timerfd_settimer 需要哪些包含文件。

谢谢埃格

4

1 回答 1

3

对这些功能的支持是 linux 和 glibc 中的新功能,您需要 linux 内核 2.6.25 或更高版本以及glibc 2.8 或更高版本。

于 2008-10-25T16:37:54.790 回答