symbols not defined

I'm trying to use this library ssem.h and sshm.h, but I'm getting the following error message:


% g++ -o Proc1 Proc1.C ssem.o sshm.o
Undefined                       first referenced
 symbol                             in file
sem_create                          /var/tmp/ccGWnoge.o
sem_signal                          /var/tmp/ccGWnoge.o
sem_wait                            /var/tmp/ccGWnoge.o
ld: fatal: Symbol referencing errors. No output written to Proc1
collect2: ld returned 1 exit status


even though I include them in my code

Proc1.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include </home/9/dunsonm/CSE_WI_660/lab_3/ssem.h>
#include </home/9/dunsonm/CSE_WI_660/lab_3/sshm.h>

using namespace std;

int main ()
{
    int buffer[200];
    for (int i = 0; i < sizeof (buffer); i++)
    {
	buffer[i] = i;
    }
    int keyOne = 830612;
    int keyTwo = 954294;
    int semOneId = sem_create(keyOne, 0);
    int semTwoId = sem_create(keyTwo, 0);
    sem_signal(semTwoId);
    sem_wait (semOneId);
    cout << "1: Hello World" << endl;
    return 0;
}


So why isn't my code compiling? Here is ssem.h:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * ssem.h
 *
 * Header file for "Simple Semaphore Operations"
 * Version : 1.0.0
 * Date: 10 Jan 2002
 * Modifications: 10 Jan 2004 Updated for C++
 *
 */

#ifdef __cplusplus
extern "C" {
#endif

/* Functions available to the user */

int sem_create(int key, int initial_value);
int sem_open(int key);
int sem_wait(int semid);
int sem_signal(int semid);
int sem_rm(int semid);

#ifdef __cplusplus
};
#endif 


and sshm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * ssem.h
 *
 * Header file for "Simple Semaphore Operations"
 * Version : 1.0.0
 * Date: 10 Jan 2002
 * Modifications: 10 Jan 2004 Updated for C++
 *
 */

#ifdef __cplusplus
extern "C" {
#endif

/* Functions available to the user */

int sem_create(int key, int initial_value);
int sem_open(int key);
int sem_wait(int semid);
int sem_signal(int semid);
int sem_rm(int semid);

#ifdef __cplusplus
};
#endif 
Last edited on
Problem fixed. I accidently copied the wrong file in my directory using the unix copy command. I thought I copied ssem.c but I actually copied ssem.h (for the second time) even though I named it ssem.c. So I thought I had the right files even though I didn't.
Topic archived. No new replies allowed.