How do I modify Visual Studio 2015 predefined macros? - c++

I'm trying to modify a predefined environment macros in Visual Studio 2015. Specifically this: VC_IncludePath
I can see it and its value, but I can not modify it. I don't see the option to do it.

You can edit this file:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Common.props

The value of this macro is automatically generated from the versions you have set in the property pages. Select Project, Properties, Configuration Properties, General and check that the Target Platform Version and Platform Toolset are correct for your installation.

For other versions, search 'Microsoft.Cpp.Common.props' in windows explorer at C:.
You may find several depending on versions installed.
Then, right click the version you want and Open > choose VS (easier to see the lists) or any. However, no VS environment variables are there to edit.

The place to change that environment variable is in the project property page Configuration Properties -> VC++ Directories as described in the MSDN documentation.

Related

Visual Studio ignoring include directories

I am running Visual Studio Community 2017 and Windows 10. I have a project for which I have added an include-file directory under Project > Configuration Properties > VC++ Directories > Include Directories, but Visual Studio simply ignores the directory and will not find the include files. It finds the files if I hard-code the directory into the #include statement. I checked the .vcxproj file and the directory shows up there. I just updated/corrected Visual Studio to the most recent version and have since re-booted, but the problem remains. Help, please!
First, ensure that MFC is enabled in project properties > Configuration Properties > General
use of mfc must be set to static or dynamic library.
then to ensure that cl.exe is using all of the include directories that you specify, you need to go to project properties > c/c++ > general and change suppress startup banner to no /nologo.this will give you the full cl command for each source file, showing exactly what visual studio is attempting to do with the code and configuration options that you give to it.
Additional ideas for troubleshooting this kind of issue:
When using vs2015 you can try to add '#include <somenoneexistingfile.h>' to the top of any .c/.cpp and right-click on it to open a context menu and select "Open Document <somenoneexistingfile.h>. This will open a dialog showing you the actual paths being used for including. Note: This specific approach doesn't work with vs2019 or later.
Besides this, you can check if:
you edited the actual configuration (Debug/Release) which you are starting, i.e. maybe you only edited the additional-include-path for the debug-build but are trying to compile a release-build.
you edited the actual platform (x64 vs x86) which you are starting, i.e. maybe you only configured the additional-include-path for x86 but are trying to compile the x64 platform.

Where to define include or link path variables in Visual Studio 2010 (and higher)

I'm trying to build a C++ project with Visual Studio 2010 and
Properties -> Configuration Properties -> C/C++ -> General ->
Additional Include Directories uses path variables, for example APR_DIST as shown below:
..\src\test-integration;..\src\main;$(APR_DIST)\$(PlatformName)\include;$(CPPUNIT_DIST)\$(PlatformName)\include;$(PLATFORM_SDK)\include
So how do I define those variables/macros ?
I would expect to find a config file that says APR_DIST=... or someplace in
Visual Studio.
Also, I know about editing the path and click on Macros>> but I can not add or edit anything there.
They're environment variables and they're system or user-wide. It depends on your version of Windows how you can read and alter them but this answer describes it pretty well.

visual studio not seeing my include files

This may be a very simple question but I haven't been able to figure it out so any help is appreciated.
I have a header that is located in a general folder because I want to use it in several projects for example:
C:\user\geninclude\program\header.h
I created a new empty project with a very simple main, in the main I put
#include <program/header.h>
I then went to the project properties and in VC++ in include directories added C:\user\geninclude\
but when I tried to build the program the program tells me it cannot find header.h because is not in the current directory or in the build system path.
I also tried in the project properties in C/C++ general Additional Include Directories adding C:\user\geninclude\ but still the same error.
I know is something simple I am missing, but I don't know what, I am very new to this just learning.
For reference I am using Visual Studio 2013.
Thank you in advance for your help.
UPDATE: Thank you all for your kind responses, I have tried everything you have told me (check release vs debug in both instances, change / for \ and <> for "", and double checking the header and still the system does not see it. It really is very weird. I'll keep trying...
Please check if your file is really an header file otherwise it won't appear on include.
What you can also do (as a workaround if you need that method fast) is to put your header file (or folder with header files) on the visual studio "include" folder. The path should look like this "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
PS: You should also check the properties configuration when you're adding the path to VC++ include directories. You could be adding the path to debug configuration and trying to run it in release mode.
You do indeed want
Project Properties -> Configuration Properties -> C/C++ -> Additional Include Directories
(or something close to that; I'm using VS 2008). Make sure the configuration you're editing in the top left (debug/release) matches the configuration you're building with (typically visible up top in the main window). So it sounds like you may have done it correctly; I'd double-check for the file's existence in that location. You could also try program\header.h instead of program/header.h. If none of those work, try adding C:\user\geninclude\program to the include directories (no \ at the end) and change it to #include "header.h". If that doesn't work either, you've almost surely got the header file in the wrong spot.
Another thing that can cause include files not being picked up is a difference between the platform set in your c++ project's Property Pages and your "Active Solution Platform" in configuration manager. Can just check if one is set to x64 and the other x86
check if you have specified the path correctly. for example I had written cpp instead of c++ and therefore suffered a lot and wasted like an hour searching here and there.
For Visual Studio 2019 users:
Project(P) > yours_project_name properties(P) > Platform Toolset Visual Studio 2019(V###)
Reasoning: You might download the project from Online and they used other version of Visual Studio as Platform.
Project(P) > yours_project_name properties(P) > Windows SDK Version ##.#(latest installed version).
Reasoning: You might download the project from Online and they used version SDK 8.0 while you have SDK 10.0
ntucvhw

Environment variable overridden in Visual Studio?

I'm using Visual Studio Express 2013 and trying to compile someone else's code. The documentation tells me to set the environment variable QTDIR in the command line and then launch VS from that terminal. But the compiler still thinks QTDIR is what it originally was instead of what I specified in the command line.
I've tried to restart the computer and do it again, but the result didn't change. I looked into the project properties, but found nothing that seems to be overriding this variable. And when I clicked the "Macros>>" button in dialogs such as the editing additional include directories dialog, it says QTDIR is what it was originally. (Weirdly: this happens only to one project in the solution; when I opened the Macros>> from other projects, QTDIR is what I specified in the command line!)
So I was wondering if there is something that can override an environment variable like this in Visual Studio. Thanks!
Edit: The confusing part is when I looked at the property pages of the projects, under Common Properties >> User Macros and there's nothing defined there.
I can only tell you about VS 2010, but in that one, macros can be defined on a per-project basis in Project Properties > Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions. You might look there.
It sounds like there is a user-defined macro for QTDIR in your project that you need to remove.
Try the following:
1) Open your solution in VS2013
2) Open the Property Manager by going to View >> Other Windows >> Property Manager
Now you you'll see a hierarchy of Projects, Configurations, and Property Sheets. The User Macro you need to remove will be set in one of these property sheets (probably the one that ends in .user).
3) Open each property sheet (one at at time!), and find the QTDIR Macro under Common Properties >> User Macros. If it's there, select it and click Remove Macro.
Hope this helps!
Source: http://msdn.microsoft.com/en-us/library/669zx6zc.aspx

fatal error LNK1112, VC++ Directories location in MS Visual Studio 2012?

This is a question to a specific answer given for this question. In trying to get Qt 5.0.2 64-bit version to build my project inside Microsoft visual studio 2012 on the Windows 7, 64-bit PC. I suspect that I've got a 32-bit version of the library even though it claims to be a 64-bit version. In any case, to get to the point:
In this answer: https://stackoverflow.com/a/4364020/2903608 and the following point: 4. Refers to the Path:
Tool > Options, Project and Solution > VC++ Directories
However, in Microsoft visual studio 2012 that tab contains the following information:
"VC++ Directories editing in Tools > Options has been deprecated.
VC++ Directories are now available as a user property sheet that is added by default all project. Please click '?' for more information."
Unfortunately, it is not possible to click anything within the tab to reach that 'more information'..
So I turn to Google for further information and came upon the following long winded page (see bullet at bottom): http://social.msdn.microsoft.com/Forums/vstudio/en-US/a494abb8-3561-4ebe-9eb0-6f644a679862/visual-studio-2010-professional-how-to-add-include-directory-for-all-projects?forum=vcgeneral, which I believe I can summarise by the following question:
Is the deprecated path that I'm looking for accessible here:
PROJECT > project_name Properties, Configuration Properties > VC++ Directories
If that's the case, I have tried modifying the entry for "Executable Directories" but it appears to have no visible effect. Even if I butcher that entry with a clearly invalid choice, there is no apparent difference to the error message.
The same source also contains the suggestion:
"VC++ Directories are no longer supported in VS2010 through Tools->Options page.
Instead, VS2010 introduces the user settings file (Microsoft.cpp.<Platform>.users.props)
to control global settings including Global search path. These files are located at
$(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory. Upon migration to VS2010,
the custom settings of VC++ Directories from VS2005 or VS2008 are migrated to these user
files. These global settings files are imported into all the converted and newly created projects."
But when I attempt to follow the path described above, I only get as far as \local\Microsoft\ so that appears to be a dead end.
Actually, the blog linked in that page is probably more useful to read: http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx
This made it when i had the error:
First, check that your properties options in your linker settings at: Properties > Configuration Properties > Linker > Advanced > Target Machine. Select MachineX64 if you are targeting a 64 bit build, or MachineX86 if you are making a 32 bit build.
More on the topic here http://msdn.microsoft.com/en-us/library/21ksa10x.aspx