The codes our instructor provided for us has been giving me a "no such file" error message for the line #include <mutex.h> in the following code:

/*
 *  mutex.cpp
 *  scheduling
 *
 */

#include <mutex.h>

Mutex::Mutex()
{

}

Mutex::~Mutex()
{

}

int Mutex::Lock()
{

}

int Mutex::Unlock()
{

}

The mutex.h code it is referring to is here:

/*
 *  mutex.h
 *  scheduling
 *
 */

#ifndef MUTEX_H
#define MUTEX_H

#include<pthread.h>

class Mutex
{
private:
    pthread_mutex_t mutex;
    
public:   
    /** Initializing the mutex
     */
    Mutex();
    
    /** Destroy the mutex
     */
    ~Mutex();
    
    /** Acquire the lock
     * @return The return value of pthread_mutex_lock().
     */
    int Lock();
    
    /** Release the lock
     * @return The return value of pthread_mutex_unlock().
     */
    int Unlock();
};
#endif

I've double checked and both codes are in the same directory and just in case you need to know, I am using Eclipse C/C++ and MinGW. Hopefully someone can help me out here so I can actually get started on this assignment!

when u include a file in <> brace like follows

#include <mutex.h>

it looks in the include directory.
But your file mutex.h is in your current directory. To include such file u have to do it using ""

#include "mutex.h"

That sort of worked.... mutex.cpp doesn't have an error anymore but now I have an error message in mutex.h saying:

`pthread_mutex_t' does not name a type (on line 15)

as well as

pthread.h: no such file

Also, I forgot to mention that a Makefile is included with the codes as well but I don't know how to use it within Eclipse to build the codes. Do I need this Makefile or can I just build everything using eclipse?

How about you just ask your teacher since it will be easier and more straight forward.

pthread.h: no such file

pthread.h is generally for POSIX systems like FreeBSD, NetBSD, GNU/Linux, Mac OS X and Solaris, but Microsoft Windows implementations also exist. For example, the pthreads-w32 is available and supports a subset of the Pthread API for the Windows 32-bit platform.

If you are working in windows it wont work. U have to look for
pthreads-w32 .

checkout the link
http://en.wikipedia.org/wiki/POSIX_Threads

pthread.h is generally for POSIX systems like FreeBSD, NetBSD, GNU/Linux, Mac OS X and Solaris, but Microsoft Windows implementations also exist. For example, the pthreads-w32 is available and supports a subset of the Pthread API for the Windows 32-bit platform.

If you are working in windows it wont work. U have to look for
pthreads-w32 .

checkout the link
http://en.wikipedia.org/wiki/POSIX_Threads

Thanks for pointing that out. I tired compiling it on my school's Linux computer and there wasn't a problem. I'm not sure whether our instructor is okay with us using pthreads-w32 so I'll have to ask her about that...

Also, this is for another assignment but what about arpa/inet.h or sys/socket.h? Are those also only supported by unix-like systems?

How about you just ask your teacher since it will be easier and more straight forward.

Yep, I'll be seeing her today.

Also, this is for another assignment but what about arpa/inet.h or sys/socket.h? Are those also only supported by unix-like systems?

Yes.

Yes.

Alright, thanks for letting me know!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.