Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 2nd, 2008, 7:50 AM   #1
secrecy230
Newbie
 
Join Date: May 2005
Posts: 11
Rep Power: 0 secrecy230 is on a distinguished road
what gcc -lrt do???

I was trying the following code but get an error

c Syntax (Toggle Plain Text)
  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?

Last edited by big_k105; May 2nd, 2008 at 10:06 AM.
secrecy230 is offline   Reply With Quote
Old May 2nd, 2008, 11:21 AM   #2
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
Re: what gcc -lrt do???

-lrt links librt
mbd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up gcc in Cygwin bigguy C 1 Aug 8th, 2007 7:03 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:46 PM.

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