0

I am developing a simple C++ application in VS2015. I am getting the error message "Cannot open source file "math". So I right click the project in the solution explorer and navigate to the VC++ Directories, click the "Include Directories" entry in the right-hand pane, pull down the combo box and choose "".

The "Include Directories" dialog appears and is completely read only. I can click the "Macros>>" button and see a list of include macros, but there is no way to add them to your project.

CloudPotato
  • 1,255
  • 1
  • 17
  • 32
Doug Kimzey
  • 1,019
  • 2
  • 17
  • 32
  • 1
    Well, what is the source file "math"? Who wrote it? Where should it be located? What does it do? – Lightness Races in Orbit Aug 22 '16 at 14:55
  • Should you be using cmath? Or is this your own custom math file? – Caleb Merchant Aug 22 '16 at 14:58
  • In my VS2013, there are four buttons in the top right of the Include Directories dialog: New Entry, Delete, Move Up, Move Down .. are those removed in VS 2015? But I'd be more inclined to simply add the math source file to your project. If it's unrelated to your project, perhaps you should build it separately as a library and then link it in to your project. – yano Aug 22 '16 at 14:58
  • @yano: It's unlikely that building a _header_ and linking it to the project is going to be terribly useful. – Lightness Races in Orbit Aug 22 '16 at 14:59
  • Are you sure that's the error message? When VS can't find a header, it says "Cannot open include file", not "Cannot open source file". – molbdnilo Aug 22 '16 at 15:00
  • math.h is a standard include file that for mathematical functions such as abs(), sin(), cos(),... with Microsoft Visual C++. – Doug Kimzey Aug 22 '16 at 15:00
  • @LightnessRacesinOrbit I agree,, he said "source file" which makes me think code.. how do you know this is a header file? – yano Aug 22 '16 at 15:00
  • The error is: "cannot open source file "math.h" This usually suggests that I do not have the include file path in the project. The Include Directory dialog has arrow buttons and a delete button. There does not seem to be any way to add Macros to the project. Macros that are shown in the Include Directories entry under configuration properties are not shown anywhere in the "Include Directories: dialog. – Doug Kimzey Aug 22 '16 at 15:02
  • @LightnessRacesinOrbit Ahhh, right you are – yano Aug 22 '16 at 15:04
  • The error is: "cannot open source file "math.h" for the source code line #include This usually suggests that I do not have the include file path in the project. The Include Directory dialog has arrow buttons and a delete button. There does not seem to be any way to add Macros to the project. Macros that are shown in the Include Directories entry under configuration properties are not shown anywhere in the "Include Directories: dialog. – Doug Kimzey Aug 22 '16 at 15:08
  • @DougKimzey: You're not paying [any] attention to detail. Is it "math.h", or is it "math"? Your question and your previous comment says the latter, but then your previous comment also says the former. The former is a standard header, whereas the latter doesn't exist unless you added it yourself. So which is it? – Lightness Races in Orbit Aug 22 '16 at 15:18
  • @yano: Because he is trying to configure include paths (and because we all know he's typoing `cmath` or `math.h`). – Lightness Races in Orbit Aug 22 '16 at 15:18
  • I understood as question "how to modify include in V2015". When I answered this, I was downrated. So what exactly is the question? @Doug: Could you also please post the error-code? (The code like _C1083_) – Bernhard Heinrich Aug 22 '16 at 15:25
  • The actual syntax is #include . No error code appears in the the Error list. Just the message "cannot open source file "math.h". – Doug Kimzey Aug 22 '16 at 15:30
  • @DougKimzey: That is not possible. Attempting to include the file `` will not produce an error about the file `math.h`. The two files are different and unrelated. Also, one appears not to exist. Look closer. – Lightness Races in Orbit Aug 22 '16 at 18:04
  • @BernhardHeinrich: The OP doesn't know what the question is, because they think their problem is being unable to add a new Include directory, when the problem is _actually_ that they misspelt the header's filename. – Lightness Races in Orbit Aug 22 '16 at 18:07

1 Answers1

-1

All configuration-dependant properties, including the INCLUDE, are edited in the property-sheets:

  • Open the Tab "Property Manager", navigate to your configuration (i.e. "Debug | 64"), double click, and enter the include path there. (Save your edits)
  • Additional project-dependant INCLUDE: Open project's properties (project/Properties in Solution Manager. Navigate to "C++/Additional includes". There you can set additional includes, even if other parts of the property-dialog are readonly).
  • Math: Following include should be available from VS2015 environment:

    #include <math.h>

  • Hi Bernhard - Thanks for the reply. Could you clarify "Property Manager"? Is this the "Property Pages" dialog? Also, are you double-clicking the "Include Directories" entry? Lastly, the "Include Directories" dialog that is launched by selecting from the combo-box for Include Directories simply launches a read-only dialog that has no active controls. – Doug Kimzey Aug 22 '16 at 15:23
  • The "Property Manager" is a Window like the "Solution Manager" window. (usually tabbed next to "Solution Manager"). You also find it in **View -> Other Windows**. Right: this window is very different from the readonly project's property dialog. – Bernhard Heinrich Aug 22 '16 at 15:42
  • Okay, perhaps you have the following (solved) [issue](http://stackoverflow.com/questions/10179201/cannot-find-property-manager-option-in-visual-studio-not-express-version) – Bernhard Heinrich Aug 22 '16 at 15:49
  • Hi Bernhard - Thanks for the clarification. This "Include Directories" dialog allows edits. – Doug Kimzey Aug 22 '16 at 15:50
  • Thanks to all - will do some additional investigation on my end on locations of math.h and other standard headers for different platform and target configurations. – Doug Kimzey Aug 22 '16 at 15:53
  • @DougKimzey: If you want to use `math.h`, don't write `math`. It's that simple. – Lightness Races in Orbit Aug 22 '16 at 18:07