I'm trying to add the header file afxwin.h to my QT project. The include path I added to my project file is below.
INCLUDEPATH += C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include
This is not behaving correctly, as it does not include the headers I'm looking for.
It highlights the "include" portion of the path in Red and when hovering over it displays;
include(filename)
[Conditional]
Includes the contents of the file specified by filename into the current project at the point where it is included. This function succeeds if filename is included; otherwise it fails. The included file is processed immediately
Is there a way to escape the include ? I have tried double quotes and it appears to have no effect. Any Ideas ?
Usually double qutoes should work, but if they don't work for what reason ever you can always try using the old 8.3 format:
INCLUDEPATH += C:\PROGRA~1\MICROS~1.0\VC\atlmfc\include
Keep in mind it isn't necessarily ~1 all the time, it could as well be ~2, ~3 etc.
You can use dir /x /p on C: and C:\Program Files (x86) in order to find out the short names for "Program Files (x86)" and "Microsoft Visual Studio 10.0".
Related
In Visual Studio Code, I am trying to get a very basic ESP Arduino project to compile.
My includePath entry in c_cpp_properties.json file looks like this:
Inside the 2.7.4 folder, there is a header file pins_arduino.h in the following path:
variants/generic/pins_arduino.h
When I try to compile the project with the following include:
#include "variants/generic/pins_arduino.h"
it does not compile, because:
app:1:31: fatal error: variants/generic/pins_arduino.h: No such file or directory
but when I remove the relative path and rely on the recursion of the includePath it compiles:
#include "pins_arduino.h"
However, the IDE does not recognize any definitions from pins_arduino.h file and marks all of them in red (so even the IDE does not find the definitions, it can compile, because of the recursion ** probably).
Removing the recursion from the includePath did not help, I still get the same compilation error when I use the relative path of the header file.
I am building using Ardiuni Extension (if I understand the concept correctly):
and I have not task.json file.
Why can't I include specific header files using their relative path from sub-folders? Is this some limitation in VS-Code or in C/C++ extension? I do not like using the recursion because I like to specify exactly the header I wanna include using its relative path without including every single folder in the includePath.
In my Qt 5.9.1 project, I wanted to add version info to the executable to help with debugging. So, I added VERSION = 1.0.0 to the 'Project.pro' file, which automatically generated a 'Project_resource.rc' file, as expected from Qt Version.
However, the project now fails to compile, giving the error RC1015: cannot open include file 'windows.h' on the line #include <windows.h> in 'Project_resource.rc'. I know that windows.h is known by the compiler at another point in the program, because in main.cpp I #include <windows.h> and use a function from there, and that successfully compiles. I just can't figure out why the 'Project_resource.rc' can't find that same file.
Note: I have the following above the VERSION = 1.0.0 line in 'Project.pro', which is how my main.cpp can find <windows.h>.
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt/x64"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/um"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um/x64"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/shared"
Remember .rc files have their own AdditionalIncludeDirectories.
It's possible that your project had set the Windows SDK properly set as one of the Include Directories values (hence your .cpp file resolves the windows.h header file) but not the .rc file (which would explain why windows.h can't be resolved from it).
If you're using Visual Studio 2019, try this:
Right click your .rc file on the Solution Explorer
Go to Resources -> General
Edit the Additional Include Directories
Include $(WindowsSDK_IncludePath) Macro
Be sure to accept and save the change.
You should stop seeing this error right after having done this.
If the ".rc file cannot open include file" was referring to a different file, just try the same but use the proper macro/path value on step 4.
My application contains multiple sub folders, that can go quite deep, e.g.
library\management\security\descriptor\configurations
(this is just a fictive example)
If another part of my application needs an include file of this folder it writes this:
#include "library\management\security\descriptor\configurations\config.h"
The problem is that if the file that contains this include is also in a quite deep path, like this:
people\groups\interestgroups\manager.cpp
And we have checked out our project in the folder:
E:\jenkins\workspace\application\release\flavour
Then the Visual Studio compiler (we compile using the /I. (slash-I-dot) option) first looks for the file in this location:
E:\jenkins\workspace\application\release\flavour\people\groups\interestgroups\library\management\security\descriptor\configurations\config.h"
And then only in
E:\jenkins\workspace\application\release\flavour\library\management\security\descriptor\configurations\config.h"
(this behavior is described in http://msdn.microsoft.com/en-us/library/vstudio/36k2cdd4(v=vs.100).aspx).
So it insists in looking first in the place where the compiled file is, and then only looking at the /I option.
The problem is that the place where the compiler looks first results in a filename that is too long (>256 characters) and the compiler just gives up.
Is there a way to tell Visual Studio to not stop when an include path is too long? Preferably without using the bracket include format (#include <>).
You can just make file in interestgroups folder that only include config.h file and you just include interestgroups file and use that file
I have a bunch of these errors and am at a dead end.
Found plenty of answers on google but unfortunately none of them work
I am using Visual Studio 2012.
All the files it says is cant find are on my computer in this folder
C:\Program Files\Microsoft Visual Studio 11.0\VC\include
Even when I right click on the include statement and click on 'Open Document ' it takes me to the document, so it is clearly there and can be seen
I tried adding the directory to the 'Additional Directories' field in options too but did not solve it.
If I use the include statement with the full path like so :
#include <C:\Program Files\Microsoft Visual Studio 11.0\VC\include\math.h>
Then is works but if the math.h file has any include statements I need to add the path to them as well and so on.
Any Idea what is happening and what else I can try?
EDIT: Going to try and create a new project from scratch and see if that helps. It is possible I touched a settings I shouldn't have
Right-click your project, go to Properties, then go to VC++ Directories and open the editor for Include Directories. There should be a tick box labelled "Inherit from parent or project defaults". You will see that Visual Studio includes some predefined directories.
If the box is already ticked and Visual Studio isn't finding the directories then try adding these directories yourself:
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSDK_IncludePath)
The following is not correct in multiple ways:
#include <C:\Program Files\Microsoft Visual Studio 11.0\VC\include\math.h>
\... begins a so called escape sequence, therefore you are putting the special tokens \P, \M, \V, \i and \m into the string, but unlike for example \n, which denotes a the newline character, these do not exist as valid escape sequences. This can be fixed by using forward slash consistently:
#include <C:/Program Files/Microsoft Visual Studio 11.0/VC/include/math.h>
However, math.h is a standard header. For standard headers, you don't write the full path. For non-standard headers, you add the include-path to the project setup, and don't write the full path neither.
#include <math.h>
Then: You are in C++, not in C. The C++ equivalents of the C-headers usually have the .h extension removed, and a c appended to the front:
#include <cmath>
I've just had the same problem, and my solution was simply to place the filename in quotes instead of angle brackets.
So, instead of < dog.h> , "dog.h" solved the "file not found" problem.
This is a bug in Visual Studio that Micosoft has set to "Closed - not a bug" see the link
https://developercommunity.visualstudio.com/content/problem/311530/win10-sdk-broken.html
I searched my PC for math.h and found it in a sub folder under "Program Files\Unity", i.e. Visual Studio did not install it. I seem to have the reverse midas touch this weekend, everything I touch turns to crap.
Retarget the project under the solution properties.
I have a visual studio solution myvs.sln with the following path: c:\dir1\dir2\dir3\myvs\myvs\myvs.sln. I have boost version xxx installed in c:\dir1\dir2\dir3\boostxxx\.
I have in the project->properties->c/c++->general: ../..;../../boostxxx. Inside boost libraries the include files have the following syntax: #include <boost/smart_ptr/shared_ptr>.
My code file myfile.h resides in c:\dir1\dir2\dir3\yy1\myfile.h. In myfile.h I include boost libraries as: #include <boost/shared_ptr.hpp>. I am getting a error which says: c:\dir1\dir2\dir3\yyy1/myfile.h fatal error C1083 cannot open include file boost/shared_ptr.hpp.
The question is what should I do to correct this?
I also notice that the error output the compiler throws has "\" upto dir3 and then changes to "/".
Most probably I do not understand how the relative path is working. Also note that I want to refer to only relative path not absolute paths. Can someone please help? I am in windows platform using c++ visual studio 2010.
Relative paths in the search paths refer to the directory of the file with the #include directive the current directory of the compiler, some simple testing now shows.
"..\.." is going up two levels from your header file the current directory of the compiler instead of from your project directory.
To fix this, explicitly start your include paths in your Visual Studio project directory, as follows (literally):
$(ProjectDir)..\..;$(ProjectDir)..\..\BoostXXX
Regarding forward versus backward slash, use forward slash in your C++ code's #include directives, because that's most portable.
Use either forward or backward slash (but I prefer backwards slash so as to have a single convention) where you're referring to the Windows file system, such as in the setup of include paths.