0

Hello I want to use pthreads in Visual C++, VS2012. I downloaded the release file but I don't know how to include and load it for VS2012, as it gives such error IntelliSense: cannot open source file "pthread.h"

2
  • Like any compiler, it has to know where your include files reside. You set that in the project properties. Nov 30, 2012 at 1:00
  • You know vs2012 supports the C++11 standard thread library, right? Just checking. Nov 30, 2012 at 1:11

3 Answers 3

1

Right click on project -> properties -> C/C++ -> General -> Additional include directories.

Add the directory there.

For the libraries, go to Linker -> General and add the directory with the libs, then go to Linker -> Input and add the libraries themselves.

Also, note that IntelliSense isn't a compiler, so that might even be a false positive error.

6
  • Still it does not work: sourceware.org/pub/pthreads-win32/… I downloaded this and I am including Pre-built.2/dll/x86 folder to those places and added dll names to input part.
    – Sarp Kaya
    Nov 30, 2012 at 1:14
  • @SarpKaya "doesn't work" without an error message is the most useless feedback you can give. Nov 30, 2012 at 1:15
  • the same error as I posted "IntelliSense: cannot open source file "pthread.h""
    – Sarp Kaya
    Nov 30, 2012 at 1:16
  • @SarpKaya I find screenshots of the property pages most helpful in remotely troubleshooting these types of situations. Nov 30, 2012 at 1:17
  • @SarpKaya as mentioned before, Intellisense is not a compiler. Have you tried actually compiling the code? Nov 30, 2012 at 1:18
0

Right click on the project and select the property pages. Then add path to the includes and the library to VC++ Directories. In the linker section, add the lib file name itself (likely pthreads.lib).

2
  • I'd advise against modifying the VC++ directories for this. There are better options available. Nov 30, 2012 at 1:10
  • There is no difference between changing the additional include directories and the VC++ directories really. Nov 30, 2012 at 1:17
0

There is a difference between "Additional Include Directories" and "VC++ Directories":

  1. Additional Include Directories is encapsulated within the Project File. So making changes here does not break or modify the compilation or linking of any other project you work on.

  2. VC++ Directories is shared by all projects you build with that compiler. You can easily break other projects by modifying what you find here.

To avoid breaking (sometimes in very subtle and confusing ways) unrelated projects, it is preferable to encapsulate your directory settings within a particular project by setting Additional Include Directories (and equivalent for libs).

1
  • Actually, VC++ Directories is a project property now, as of VS2010.
    – HotOil
    Jul 8, 2014 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.