[LCP]shm_open int linux

David Filion filiond at videotron.ca
Sun Oct 13 08:29:01 UTC 2002


Hi all,

Does linux support shm_open()?

I found the declaration in sys/mman.h (glibc 2.2.5) but when I call the
function (see test program bellow) I get:

$ gcc -g try.c 
/tmp/ccWn5Sa7.o: In function `main':
/home/filioda/tmp/try.c:14: undefined reference to `shm_open'
/home/filioda/tmp/try.c:18: undefined reference to `shm_unlink'
collect2: ld returned 1 exit status

Am I just missing a library?

-------- try.c start -----------------
/* This is just to test if the function is found in the libs. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>

int
main (void)
{
	int i;

	i = shm_open ("/tmp/shared", O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
	printf ("shm_open rc = %d\n", i);
	
	shm_unlink ("/tmp/shared");

	return (0);
}

-------- try.c end -----------------





More information about the linuxCprogramming mailing list