Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Visual Studio look for C++ header files?

I checked out a copy of a C++ application from SourceForge (HoboCopy, if you're curious) and tried to compile it.

Visual Studio tells me that it can't find a particular header file. I found the file in the source tree, but where do I need to put it, so that it will be found when compiling?

Are there special directories?

like image 834
Brian Sullivan Avatar asked Dec 02 '08 20:12

Brian Sullivan


People also ask

Where does C look for header files?

GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets.

How do I add a header file to Visual Studio project?

Place your caret on the first line of any C# or Visual Basic file. Press Ctrl+. to trigger the Quick Actions and Refactorings menu. Select Add file header. To apply the file header to an entire project or solution, select Project or Solution under the Fix all occurrences in: option.

Where are header files stored in Vscode?

1 Answer. Show activity on this post. Open the Command Palette ( F1 or Ctrl+Shift+P ), look for "C/C++: Edit configurations (UI)", and add the desired folders under "Include path". This will allow Visual Studio Code's IntelliSense to know where your header files are located.

How do I add a header file in Visual Studio C++?

To create a header file for a new class, right-click to open the shortcut menu for the MathLibrary project in Solution Explorer, and then choose Add > New Item. In the Add New Item dialog box, select Visual C++ > Code. In the center pane, select Header File (. h).


1 Answers

Visual Studio looks for headers in this order:

  • In the current source directory.
  • In the Additional Include Directories in the project properties (Project -> [project name] Properties, under C/C++ | General).
  • In the Visual Studio C++ Include directories under ToolsOptionsProjects and SolutionsVC++ Directories.
  • In new versions of Visual Studio (2015+) the above option is deprecated and a list of default include directories is available at Project PropertiesConfigurationVC++ Directories

In your case, add the directory that the header is to the project properties (Project PropertiesConfigurationC/C++GeneralAdditional Include Directories).

like image 56
Rob Prouse Avatar answered Oct 19 '22 07:10

Rob Prouse