Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, January 23, 2020 7:03 PM
I am trying to create my own includes files but I get an error "cannot open source file "XXX.h" in VS2019.
I have tried project properties->VC++ Directories->Include directories.
I have also tried project properties->C/C++->Additional Include Directories.
None of these work. What does for if I specify #include <c:\include\XXX.h> Or from the command line if I run cl /I C:\INCLUDE TestCPP.cpp.
All replies (6)
Thursday, January 23, 2020 11:28 PM
The big thing about this is that if you look at the Visual C++ project properties, the Additional Include Directories option sets the /I compiler option.
If you look at the description it does state that it sets /I.
This is the option that it passes to cl.exe. So since the documentation states that the space in the /I is optional, there is no difference in what you passed to the compiler on the command like and what the Additional Include Directories option sets is the same.
What's more, with this set:
Then:
Visual Studio has no issues finding this header. So exactly how did you set these options? Did you remember to set them for all configurations and platforms?
After all the Visual Studio property pages can be set to completely different configuration options than the main UI window. This is why I used All Configurations/All Platforms when I set options like these.
This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Friday, January 24, 2020 5:50 PM
Thanks for the detailed post. I am still having issues. i have attached screenshots. I am using VS 2019 16.4.3
Saturday, January 25, 2020 12:20 PM
Read Darran Rowe's post again.
Project properties can differ for the available configurations (Debug, Release) and platforms (x86, x64).
You set the project property for the x64 Platform but are trying to build with the x86 Platform.
Saturday, January 25, 2020 12:43 PM | 1 vote
If you notice, I have the properties window set to All Configurations and All Platforms:
This was deliberate. This will set the setting for all Configuration/Platform pairs at the same time. Unless you need to set a setting for an individual configuration/platform, it is best to keep the properties window set like this.
This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Saturday, January 25, 2020 4:47 PM
That worked thanks!
Monday, January 27, 2020 6:26 AM
Hi superbovine,
Sorry to bother you.
If the reply could be helpful for you, please mark it as answer, it will be beneficial to other community members who has similar issue.
If you have other questions about VS IDE, please feel free to contact us, we will try our best to provide a solution.
Have a nice day.
Best Regards,
Dylan
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]