Visual Studio 2022 intellisense includePath errors - c++

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)

Related

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.

Where is the Project Directory in Microsoft Visual Studio?

Where is the project directory in microsoft visual studio C++? How can you add files so that in your line of code you can write #include "myfile"? Thanks...
Add the directory containing your file to the include directories list:
Project -> Properties -> Configuration Properties -> C/C++ -> Additional Include Directories
Usually a Visual Studio project directory is a sub-directory of a solution directory. However, it doesn't need to be. E.g. you can add a project to multiple solutions.
For any given project, in the project settings the location of the project directory is available via the $(ProjectDir) macro expansion.
You can also use such macro expansions to access ordinary environment variables.
The difference between #include "blah" and #include <blah> is that the former adds a compiler-dependent additional search for the header, before (if that fails) doing the same search as the latter. With most (all?) modern compilers the additional search includes searching in the directory of the including file. Thus,
one way to add a file so that you can write just #include "myfile" in your code, is to place the file in the same directory as the including code.

Importing Dlls in Visual Studio

I am able to create Dlls and am able to access their header files by manually adding the file path of the .lib file to Project Properties -> VC++ Directories -> Library Directories as well as Proj Properties -> C/C++ -> Additional Include Directories. Everything works properly when I do this, BUT every time I open my project on a new machine I have to manually change all of these paths.
I tried setting them to relative paths instead (i.e. ..\ProjectName\Debug) but this did not work. Is there any way to include the necessary library files in my project so that the project will work automatically no matter which machine it is on?
Relative paths should be fine. It didn't work for you because you set incorrect paths I guess.
If .. confuses you and you are not sure what directory it refers to, you can use macros that are defined within Visual Studio IDE like $(SolutionDir) or $(ProjectDir). Note that these macros include / at the end so when you specify path by using them it looks like this: $(SolutionDir)dep/include.
Hope this helps.

How to make the visual studio 2008 IDE look at the right place for header files. Compiling Qt/C++ program

I am building an app on Qt 4.6.2 using visual studio 2008. I need to include the header <QtGui\QDir>.
Problem : The QDir header includes several headers. Once of them is qfile.h. Now the ide/compiler is unable to include this file and the error I get is this
c:\devprojects\myprojects\nttoolkit\trunk\external\qt\include\qtcore../../src/corelib/io/qfile.h(45)
: fatal error C1083: Cannot open
include file:
'Qt/include/QtCore/qiodevice.h': No
such file or directory
I cannot change the path in the file qfile.h since it is an external file to my project. How do I get it working.
Thanks.
The various places the preprocessor searches for include files is described in the Remarks section here.
Typically for an "SDK" like Qt people will change their VC++ Directories, Projects, Options under Tools | Options | "Projects and Solutions" | "VC++ Directories" so that the Include Files and Library Files lists include suitable Qt directories. That way, when the preprocessor searches for Qt include files, it will look in the right places and when the linker looks for .LIB files it will find them also.
One downside to changing those lists is that they apply to all projects built from that version of Visual Studio. That can be a pain in the neck if you have different projects that use different versions of an SDK. In those sorts of situations one solution is to create environment variables called INCLUDE and LIBPATH and then launch devenv with the /useenv switch to override the VC++ Directories settings from Tools | Options.
Finally, a third option is to provide the additional include and library folders via the project properties. In Project | Properties | C++ | General the first property is "Additional Include Directories". Values placed there are passed to the preprocessor via the /I switch. Similarly the Project | Properties | Linker | General tab has an "Additional Library Directories" property which gets passed to the linker via the /LIBPATH switch.
This third option seems attractive because it lets you set these additional directories on a project by project basis. The downside is that it "hard-codes" some directory names in the project. That can be a real pain if you move the project to a new machine where the Qt files are in a different directory or when you have to move the Qt directories to a different hard-drive, etc.
In VS2010, I go to:
Project Properties -> VC++ Directories -> Include Directories
And set the location of directories containing headers I need to include. I don't currently have access to a VS2008 install, but I think there is a similar configuration option available.

C++ Specify Headers Include Directory in Code

Is there a way to specify include directories in the code, perhaps via a #pragma?
I have my project setup as "src/" and "include/" folders. I am trying to compile in Visual Studio 2010, but I don't want to set it up in the project settings.
Is there another way to allow it to compile instead of having to specify the include as
#include ../include/ss.h
The Correct(tm) way to specify search directories is with compiler flags. In Visual Studio you do this by playing with the project settings, or its compiler's /I commandline parameter.
In Visual studio, you can also define include folders by setting them via Options/File Locations. Then you don't need to repeat them in every project setting. (Assuming that's what you're after). It is a bit weird to define absolute paths in source code, you'll never know from which folder/drive a build is run.