Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Eliana Stavrou" Reply-To: iouliani AT cytanet DOT com DOT cy To: cygwin AT cygwin DOT com Date: Mon, 3 Nov 2003 00:32:24 eet Subject: undefined reference to _shmget Message-id: <3fa5e868.1540.0@cytanet.com.cy> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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 #include #include #include #include #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/