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

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2007
Posts: 22
Reputation: pocku is an unknown quantity at this point 
Solved Threads: 0
pocku pocku is offline Offline
Newbie Poster

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

 
0
  #1
Oct 13th, 2009
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:

  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:

  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!
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 357
Reputation: dkalita will become famous soon enough dkalita will become famous soon enough 
Solved Threads: 55
dkalita's Avatar
dkalita dkalita is offline Offline
Posting Whiz
 
0
  #2
Oct 13th, 2009
when u include a file in <> brace like follows
  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 ""
  1. #include "mutex.h"
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: pocku is an unknown quantity at this point 
Solved Threads: 0
pocku pocku is offline Offline
Newbie Poster
 
0
  #3
Oct 13th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,356
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 171
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso
 
0
  #4
Oct 13th, 2009
How about you just ask your teacher since it will be easier and more straight forward.
1) What word becomes shorter if you add a letter to it? 
      [ Solved by : niek_e, Paul Thompson, SgtMe, murtan, xavier666, jonsca]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
      [*solved by : murtan, xavier666]
3) What is the 123456789th prime numer?
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 357
Reputation: dkalita will become famous soon enough dkalita will become famous soon enough 
Solved Threads: 55
dkalita's Avatar
dkalita dkalita is offline Offline
Posting Whiz
 
0
  #5
Oct 13th, 2009
Originally Posted by pocku View Post
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: pocku is an unknown quantity at this point 
Solved Threads: 0
pocku pocku is offline Offline
Newbie Poster
 
0
  #6
Oct 13th, 2009
Originally Posted by dkalita View Post
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.
Last edited by pocku; Oct 13th, 2009 at 4:18 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 357
Reputation: dkalita will become famous soon enough dkalita will become famous soon enough 
Solved Threads: 55
dkalita's Avatar
dkalita dkalita is offline Offline
Posting Whiz
 
0
  #7
Oct 14th, 2009
Originally Posted by pocku View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: pocku is an unknown quantity at this point 
Solved Threads: 0
pocku pocku is offline Offline
Newbie Poster
 
0
  #8
Oct 15th, 2009
Originally Posted by dkalita View Post
Yes.
Alright, thanks for letting me know!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC