У меня просто сбой системы и переустановка Ubuntu 11.10, и мой код вызывает эту странную ошибку.
Я написал простой пример кода, чтобы проверить, где проблема:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
int main (void) {
int i;
i = shm_open ("/tmp/shared", O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); printf ("shm_open rc = %d\n", i);
shm_unlink ("/tmp/shared");
return (0);
}
и команда компиляции
gcc -lrt test.c -o test
Ошибка:
/tmp/ccxVIUiP.o: In function `main':
test.c:(.text+0x21): undefined reference to `shm_open'
test.c:(.text+0x46): undefined reference to `shm_unlink'
collect2: ld returned 1 exit status
Я уже добавил -lrt lib, почему он еще не компилируется?