Additional Include Directories not working - c++

In Visual Studio C++, I go to the project settings, additional include directories, then add the directory of the file to the list. However, when I try to include the file, it can't find it, I've restarted Visual Studio and that doesn't work.
Here's my include directories:
A picture of my include directories
Here's the error I get:
A picture of the Error

The problem was that I was modifying the include directories under the release configuration mode
Make sure to switch to debug before modifying it.

Here is a way to add your file to the Project:
Go left click on the project and choose "Add"->"ExistingItem"
A simple file browser will open, now you can just pick the desired file and confirm.
Now you need just to #include "TheNewFile where you need the new file...

Related

Visual Studio 2022 intellisense includePath errors

when using the intellisense prompt of VS2022 to automatically include the header file in the code in the Cpp file, the following error always occurs
#include "../Config/UGConfigManager.h"
Is there any way to replace the path "../" with a full path? Like this:
#include "Game/Config/UGConfigManager.h"
EDIT:
In UE5, you need to change NMake's IncludeSearchPath instead of VC++ Directories in Properties -> NMake
You need to add an include path to the "Game" folder.
To set an include path you now must right-click a project and go to:
Properties -> VC++ Directories -> General -> Include Directories
Then add the include directory like so:
C:/foobar/Game
First try using an absolute path. And if that works you will want to use a Macro. Macros allow users to define paths without being specific to their own computer (So other people can use it).
Perhaps what you need is $(ProjectDir) but I can't tell since I don't know where "Game" is relative to your project files.
But as an example:
$(ProjectDir)/Game
It's worth pointing out that what you are doing is interacting with the compiler option /I on the MSVC compiler. Visual Studio is just a gui abstracting it away for you.
Here are the docs on /I (Additional include directories)

C++ cannot open source file, additional directory listed

I am using Visual Studio 2019, and I'm trying to include codes from open source GLFW. Things were working completely fine, but when I tried to make another project based on this method again it's not working.
It shows 'Cannot open include file: 'GLFW/glfw3.h': No such file or directory'
I reproduced the steps to add GLFW and it worked well. You could check whether there are any missing steps.
Create a Dependencies folder in your project directory, copy the include and lib-vc2019 folders of glfw-3.3.2.bin.WIN32 to Dependencies.
Set Configuration to All Configurations and set Platform to Win32
Add $(SolutionDir)Dependencies\GLFW\include in Proeperties->C/C++->General->Additional Include Directories
Add $(SolutionDir)Dependencies\GLFW\lib-vc2019 in Proeperties->Linker->General->Additional Library Directories
Add glfw3.lib;opengl32.lib;User32.lib;Gdi32.lib;%(AdditionalDependencies) in Proeperties->Linker->Input->Additional Dependencies

Boost C++ Libaries in Visual Studio 2017 C++ Project - "Cannot open include file"

I'm trying to add the Boost C++ Libraries to my C++ project created with Visual Studio 2017.
I have followed the instructions here.
When that didn't work I tried the advice in this post. Neither solutions worked for me.
What I have done:
Downloaded boost_1_69_0-msvc-14.1-64.exe from this precompiled boost libraries page
Installed to D:\local\boost_1_69_0
In my project I added D:\local\boost_1_69_0 to Properties > VC++ Directories > Include Directories and added D:\local\boost_1_69_0\lib64-msvc-14.1 to Properties > VC++ Directories > Library Directories
I have my project set to x64 and the above settings were set in the x64 configuration
When I try to build my project I get this error:
Error C1083 Cannot open include file: 'boost/regex.hpp': No such file or directory
Which points to this line of code in one of my .cpp files:
#include <boost/regex.hpp>
Please go to D:\local\boost_1_69_0 folder and see if you have a sub-folder named include in there. If you do, then instead of D:\local\boost_1_69_0 you need to set D:\local\boost_1_69_0\include in Properties > VC++ Directories > Include Directories
In other words, try to find the file you are including on your hard drive. Look at the full path to the file. Compare that full path with the path you added to the list of include directories (Properties > VC++ Directories > Include Directories) concatenated with the relative path you provided just before the filename in your include directive (boost). See if the two are the same.
If that does not help, then make sure you changed list of include directories for the same build configuration as you are attempting to build (if you build Debug, make sure you changed configuration for Debug too). Since VS 2015 IDE stopped making sure the two are selected in sync, which is annoying.
If your files are copied, then you have to compile the regular library.... If the same version of the compiler copies the machine.
Found out it was failing because I had included the same .cpp file which has the boost include into my unit test project which did NOT have the Include/Library folders set. The settings in my original question work now.

Visual C++ project can't find 'xyz.h' file for external dependencies

I have a Visual Studio C+++ project, and in the project I have some header files I want to get via the include directories setting on the project properties.
As far as I know that's all set up correctly. I've added the folder path which contains the files and the 3 files appear in the external dependencies folder under my project in Visual Studio.
The problem is that:
when I write the include "xyz.h" for one of the three files, I get "can not find file blah blah" error. This only occurs for one of the three. The other two work fine and I can include them just fine. They are all just basic headers.
Does anyone have any idea why one of my files would fail to work. Thanks
When you setting up the project properties such ad additional include directories, make sure to select "All configurations" in the project properties window. look at the image.
Sorry, the problem was that the file was being used by some background process, so the dll that I was trying to load couldn't open the file.

visual studio 2012 adding new header file

In Visual Studio 2012 (C++ environment), for a Win32 console application, I need to include a new header file to my project. I tried copying the files in the project's location but that is of no help. The file is iGraphics.h and it is shown in the header files list but does not compile. What should be the correct approach?
You should add the path to that header to the additional include directories under C/C++ in your project settings. Afterwards, just #include "iGraphics.h" where you need it.
Don't just move header files around, and don't add existing headers to your project for no good reason. This way, you can easily change versions by just specifying a different folder.
The easiest way to do this is:
Right click on the header file (to be included) in the Solution explorer.
General->"Excluded from the build"
Select "No" from the drop down list
Click "OK".
In VS2012, just using '"' instead of '<>' around the header file in include also works.
Put the file in the right place in the file system (like you did). Then right-click your project in the solution explorer and use Add > Existing Item to add it to your project.
If you don't want to move your file (which you probably should not), see Luchian's answer on how to add the include directory to the include folders.