sem_open problem

I can't compile these codes with g++.
my system is linux (kernel is 2.4.0 ).
When I try to compile this program with g++ -o semw semw.cpp
It always tells me that sem_open sem_close,sem_post do not exist.But I have checked semaphore.h,I can not find any problems.
Anyone can compile these codes in system linux ,and tell me the result ?May be it is the bug of linux ?

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <semaphore.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/stat.h>

#define FILE_MODE S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH
int main(int argc,char **argv)
{
	int c,flags,fd;
	sem_t *sem;
	
	int val;
	if (argc!=2)
		fprintf(stderr,"usage:semwait<name>");
	
	fprintf(stderr,"usage:createSem [-e][-i initalvalue ]<name>");
	//sem=sem_open(argv[1],0);
	sem_open(argv[1],0);
	sem_post(sem);
	sem_wait(sem);
	
	pause();
	exit(0);
}

added code tags for readability --oombera

I don't have access to a Linux system. But my manpage for sem_open says:

You need to look at your man page, see what it says, and follow it's instructions.

Thank you very much .You are right .I compile it ok with -lrt.
And I also checked the man page in solaris .I found that in linux
there is no man page for sem_open,maybe I missed something ?