ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: gosha <gosha@elins.ru>
To: community@lists.altlinux.org
Subject: [Comm] Пропадаю. Linux и shared memory- что я делаю не так?
Date: Tue, 1 Apr 2008 07:59:05 +0000
Message-ID: <200804010759.05342.gosha@elins.ru> (raw)

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.


             reply	other threads:[~2008-04-01  7:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01  7:59 gosha [this message]
2008-04-01  5:01 ` Michael Holzman
2008-04-01  9:47   ` gosha
2008-04-01  6:29 ` Andrey Rahmatullin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200804010759.05342.gosha@elins.ru \
    --to=gosha@elins.ru \
    --cc=community@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git