-1
我想在內核版本2.6.15的Ubuntu 6.06.2上編譯inotify simpe代碼。 我的代碼是試圖編譯簡單的inotify程序
#include <errno.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/inotify.h>
#include <unistd.h>
#include <fcntl.h>
#define IN_NONBLOCK O_NONBLOCK
int main(int argc, char* argv[])
{
char buf;
int fd, i, poll_num;
int *wd;
nfds_t nfds;
struct pollfd fds[2];
if (argc < 2) {
printf("Usage: %s PATH [PATH ...]\n", argv[0]);
exit(EXIT_FAILURE);
}
printf("Press ENTER key to terminate.\n");
/* Create the file descriptor for accessing the inotify API */
fd = inotify_init();
if (fd == -1) {
perror("inotify_init1");
exit(EXIT_FAILURE);
}
close(fd);
exit(EXIT_SUCCESS);
}
我已經安裝的libc6-dev的2.3.6也。 但是當我編譯這段代碼有
error: sys/inotify.h: No such file or directory
,當我用linux/inotify.h比我得到
/tmp/ccUTUEAq.o: In function `main':ionotify.c:(.text+0x50): undefined reference to `inotify_init'.
請有人告訴我怎樣才能解決這個問題。
'Inotify被合併到2.6.13 Linux內核中。所需的庫接口已添加到版本2.4中的glibc。 (在glib 2.5版中增加了IN_DONT_FOLLOW,IN_MASK_ADD和IN_ONLYDIR)。所以我認爲你需要libc更新 – pbn
看看[inotify_init'手冊頁](http://man7.org/linux/man-pages/man2/inotify_init.2.html)它說支持被添加到glibc 2.4。你需要升級你的(非常老的)系統。 –
感謝您的快速響應.. –