Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   what gcc -lrt do??? (http://www.programmingforums.org/showthread.php?t=15749)

secrecy230 May 2nd, 2008 7:50 AM

what gcc -lrt do???
 
I was trying the following code but get an error

:

  1. #include <sys/mman.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <fcntl.h>
  6. #include <sys/stat.h>
  7. #define MAX_LEN 10000
  8.  
  9. struct region
  10. {
  11.   int noProces ;
  12.   char buf[MAX_LEN];
  13.  
  14.  
  15. };
  16.  
  17. struct region *ptrRegion;
  18.  
  19. int main()
  20. {
  21.  
  22.   int fd = shm_open ("/home/suren/test",O_CREAT|O_RDWR,S_IRUSR|S_IWUSR);
  23.   if (fd == -1 )
  24.     {
  25.  
  26.       printf("error\n");
  27.     }
  28.  
  29.   if (ftruncate(fd,sizeof(struct region))== -1)
  30.     {
  31.  
  32.  
  33.     }
  34.  
  35.   ptrRegion= mmap(NULL,sizeof(struct region),PROT_READ | PROT_WRITE,MAP_SHARED,fd,0);
  36.  
  37.  
  38.   if (ptrRegion == MAP_FAILED)
  39.     {
  40.  
  41.  
  42.     }
  43.  
  44.  
  45.   return 0;
  46. }


I have get that error
undefined reference to shm_open
but why when i compile it in linux with gcc or cc -lrt there is no error ??
what gcc -lrt do?

mbd May 2nd, 2008 11:21 AM

Re: what gcc -lrt do???
 
-lrt links librt


All times are GMT -5. The time now is 5:02 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC