Linker error: undefined reference to `_error'

view full story

http://www.linuxforums.org – hi all, The following code gives a linker error for error() function call on my cygwin setup Code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/mman.h> #include <errno.h> main() {         pid_t pid;                 int len = 100;         int fd;                 char * buf;         char arr[] = "thread1.c";         fd = fopen(arr, "rw");         if (fd == NULL)                 error(1, errno, "fopen Failed!");         printf("file opened successfully\n");                 if (ftruncate(fd, len) == -1)                 error(1, errno, "ftruncate Failed!");         printf("file truncated to length %d bytes\n", len);                 buf = mmap(0, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);         if (buf == (void *)-1)                 error(1, errno, "ftruncate Failed!");         printf("MMAP successful!!\n");         if (unlink(fd) == -1)                 error(1, errno, "Unlink Failed!");         printf("file UNlinked\n");         pid = fork();         if (pid < 0)                 error(1, errno, "fork Failed!");         else         {                 if (pid == 0)                 {                         printf("child process sleeps\n");                         sleep(2);                         printf("child process Wakes\n");                         printf("child reads from memory:\n...%s....", buf);                         printf("child dies\n");                 }                 else                 {                         printf("Parent::accessing mapped file\n");                         strcpy(buf, "parent writes on the mapped memory");                 }         }         } The snapshot of the error is as follows: Code: /tmp/cceXgGbe.o:mmap1.c:(.text+0x69): undefined reference to `_error' /tmp/cceXgGbe.o:mmap1.c:(.text+0xab): undefined reference to `_error' /tmp/cceXgGbe.o:mmap1.c:(.text+0x120): undefined reference to `_error' /tmp/cceXgGbe.o:mmap1.c:(.text+0x15b): undefined reference to `_error' /tmp/cceXgGbe.o:mmap1.c:(.text+0x194): undefined reference to `_error' collect2: ld returned 1 exit status I might have missed selecting appropriate library during installation. Can any one suggest me which library I have to look for. cheers Sarma (HowTos)