This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

undefined reference to _shmget


Hi to you all,
 
I'm using the latest version of the cygwin and I'm having some problems
when compiling this program using gcc:
 
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <stdio.h>
 
#define SHMKEY (key_t)4321
#define SEMKEY (key_t)9876
#define SHMSIZ 256
#define PERMS 0600
 
main(){
 
int shmid,semid;char line[128];char *shmem;struct sembuf oper[1] = {0,1,0};
 
if ((shmid = shmget(SHMKEY,SHMSIZ,PERMS|IPC_CREAT)) < 0)
{perror("shmget");exit(1);}
 
printf("\nCreated shared memory region with identifier %d\n", shmid);
 
if ((semid = semget(SEMKEY,1,PERMS|IPC_CREAT)) < 0)
{perror("semget");exit(1);}
 
printf("\nCreated semaphore with identifier %d\n", semid);
 
if (semctl(semid,0,SETVAL,0) < 0) {perror("semctl");exit(1);}
 
printf("\nInitialized semphore to lock shared memory region\n");
 
if ((shmem = shmat(shmid, (char *)0,0)) == (char *) -1)
{perror("shmat");exit(1);}
 
printf("\nAttached shared memory region\n");
 
printf("Give input line: "); gets(line);
strcpy(shmem,line); 
 
printf("\nWrote to shared memory region: %s\n",line);
 
if (semop(semid,&oper[0],1) < 0) {perror("semop");exit(1);}
 
printf("\nReleased shared memory region\n");
 
} // end of main program
 
I get the following message:
 
$ gcc -o s_server.exe shm_sem_server.c

/cygdrive/c/DOCUME~1/na/LOCALS~1/Temp/ccii7ZHU.o(.text+0x1e2):shm_sem_serve
r.c:
undefined reference to `_shmget'
/cygdrive/c/DOCUME~1/na/LOCALS~1/Temp/ccii7ZHU.o(.text+0x23a):shm_sem_serve
r.c:
undefined reference to `_semget'
/cygdrive/c/DOCUME~1/na/LOCALS~1/Temp/ccii7ZHU.o(.text+0x291):shm_sem_serve
r.c:
undefined reference to `_semctl'
/cygdrive/c/DOCUME~1/na/LOCALS~1/Temp/ccii7ZHU.o(.text+0x2d4):shm_sem_serve
r.c:
undefined reference to `_shmat'
/cygdrive/c/DOCUME~1/na/LOCALS~1/Temp/ccii7ZHU.o(.text+0x36c):shm_sem_serve
r.c:
undefined reference to `_semop'
collect2: ld returned 1 exit status
 
I have checked and I have all the necessary libraries, any ideas on what is
the problem?
I can't think of anything.
 
Thank you in advance,
Eliana.
 
_____________________________
CYTANET WebMail
http://webmail.cytanet.com.cy

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]