[Comm] Пропадаю. Linux и shared memory- что я делаю не так?

gosha =?iso-8859-1?q?gosha_=CE=C1_elins=2Eru?=
Вт Апр 1 11:59:05 MSD 2008


AltLinux_4 - не собираются программы, использующие shared memory- что я мог сделать не так?



/*  ====================   shm_test.c   =========================  */
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
 
#define SHM_NAME "/tmp/shm_car_workstantion"                                                                                                   
#define SHM_SIZE 0x1000                                                                                                                                                       
int shm_fd;                                                                                           
void* shm_addr;               /* shared memory attach address */
static float *analog;
static char *control, *sensor;
/*=================================================================================================*/
static int destroy_shared_memory(void)
{if(-1 == close(shm_fd))
    {perror("close"); return -1;}
 if (-1 == shm_unlink(SHM_NAME))
       {perror("shm_unlink"); return -1;} 
 }
/*=================================================================================================*/
int main(void)
{destroy_shared_memory();
 if((shm_fd=shm_open(SHM_NAME, O_RDWR, S_IRUSR | S_IWUSR)) >=0)
   {destroy_shared_memory();}
 shm_fd = shm_open(SHM_NAME, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);                                                      
 if(shm_fd == -1) 
  {perror("shm_open"); return -1;} 
 if (ftruncate(shm_fd, (off_t) SHM_SIZE) == -1)                                                      
    {perror("ftruncate"); destroy_shared_memory();    return -1;}
 shm_addr = mmap(NULL, (size_t)(SHM_SIZE), PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, (off_t)0);
 if(shm_addr == MAP_FAILED)
    {perror("mmap"); destroy_shared_memory(); return -1;}
 memset(shm_addr, 0, (size_t)SHM_SIZE);                                           
 analog= (float *) shm_addr + 0x100;
 sensor= (char  *) shm_addr + 0x200;
 control=(char  *) shm_addr + 0x300; 
 return 1;
} 
 /*=================================================================================================*/



#gcc shm_test.c
 
/tmp/.private/gosha/ccebTZxk.o: In function `destroy_shared_memory':
shm_test.c:(.text+0x3e): undefined reference to `shm_unlink'
/tmp/.private/gosha/ccebTZxk.o: In function `main':
shm_test.c:(.text+0x96): undefined reference to `shm_open'
shm_test.c:(.text+0xc0): undefined reference to `shm_open' 
 



в /usr/include/sys/mman.h
данные ф-ии присутствуют.

Где могла собака порыться?


Спасибо.
-- 
С Уваженим,
       gosha.



Подробная информация о списке рассылки community