944,103 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 821
  • C++ RSS
Oct 13th, 2009
0

Can't get started: "no such file"...

Expand Post »
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:

C++ Syntax (Toggle Plain Text)
  1. /*
  2.  * mutex.cpp
  3.  * scheduling
  4.  *
  5.  */
  6.  
  7. #include <mutex.h>
  8.  
  9. Mutex::Mutex()
  10. {
  11.  
  12. }
  13.  
  14. Mutex::~Mutex()
  15. {
  16.  
  17. }
  18.  
  19. int Mutex::Lock()
  20. {
  21.  
  22. }
  23.  
  24. int Mutex::Unlock()
  25. {
  26.  
  27. }

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

C++ Syntax (Toggle Plain Text)
  1. /*
  2.  * mutex.h
  3.  * scheduling
  4.  *
  5.  */
  6.  
  7. #ifndef MUTEX_H
  8. #define MUTEX_H
  9.  
  10. #include<pthread.h>
  11.  
  12. class Mutex
  13. {
  14. private:
  15. pthread_mutex_t mutex;
  16.  
  17. public:
  18. /** Initializing the mutex
  19.   */
  20. Mutex();
  21.  
  22. /** Destroy the mutex
  23.   */
  24. ~Mutex();
  25.  
  26. /** Acquire the lock
  27.   * @return The return value of pthread_mutex_lock().
  28.   */
  29. int Lock();
  30.  
  31. /** Release the lock
  32.   * @return The return value of pthread_mutex_unlock().
  33.   */
  34. int Unlock();
  35. };
  36. #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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pocku is offline Offline
22 posts
since Nov 2007
Oct 13th, 2009
0
Re: Can't get started: "no such file"...
when u include a file in <> brace like follows
C++ Syntax (Toggle Plain Text)
  1. #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 ""
C++ Syntax (Toggle Plain Text)
  1. #include "mutex.h"
Reputation Points: 121
Solved Threads: 61
Posting Pro in Training
dkalita is offline Offline
402 posts
since Sep 2009
Oct 13th, 2009
0
Re: Can't get started: "no such file"...
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?
Last edited by pocku; Oct 13th, 2009 at 3:16 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pocku is offline Offline
22 posts
since Nov 2007
Oct 13th, 2009
0
Re: Can't get started: "no such file"...
How about you just ask your teacher since it will be easier and more straight forward.
Reputation Points: 840
Solved Threads: 594
Senior Poster
firstPerson is offline Offline
3,865 posts
since Dec 2008
Oct 13th, 2009
0
Re: Can't get started: "no such file"...
Click to Expand / Collapse  Quote originally posted by pocku ...
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
Reputation Points: 121
Solved Threads: 61
Posting Pro in Training
dkalita is offline Offline
402 posts
since Sep 2009
Oct 13th, 2009
0
Re: Can't get started: "no such file"...
Click to Expand / Collapse  Quote originally posted by dkalita ...
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?

Quote ...
How about you just ask your teacher since it will be easier and more straight forward.
Yep, I'll be seeing her today.
Last edited by pocku; Oct 13th, 2009 at 4:18 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pocku is offline Offline
22 posts
since Nov 2007
Oct 14th, 2009
0
Re: Can't get started: "no such file"...
Click to Expand / Collapse  Quote originally posted by pocku ...
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.
Last edited by dkalita; Oct 14th, 2009 at 1:32 am.
Reputation Points: 121
Solved Threads: 61
Posting Pro in Training
dkalita is offline Offline
402 posts
since Sep 2009
Oct 15th, 2009
0
Re: Can't get started: "no such file"...
Click to Expand / Collapse  Quote originally posted by dkalita ...
Yes.
Alright, thanks for letting me know!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pocku is offline Offline
22 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Mortgage calc..OOP
Next Thread in C++ Forum Timeline: Convert minutes to time





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC