[Reprint] Add a default include path method for Visual Studio

Source: Internet
Author: User

Original address

Have you ever had a problem like this:

With VS, sometimes use some non-self-brought libraries, such as WTL, Boost, DX, and so on, each time you need to add the appropriate include directory in the project properties, a bit of trouble. Is there a solution?

So I find relevant information on the Internet, on the StackOverflow website to find a related article (original link), the article mentioned in one way is to modify

C:\users\<user>\appdata\local\microsoft\msbuild\v4.0\microsoft.cpp.win32.user.props this file, In this file to add the need to include the directory, I have been using this method, there is no problem.

When I installed the VS2012, the problem changed. In the VS2012 of a new MFC project, nothing moved, incredibly compiled does not pass, the hint can not find some files, I would like to think is not before modified the impact, so I decided to change the file to restore the default content, and then try, the result is no problem ... However, you have to manually add the WTL directory every time. I started to turn over some of the VS's configuration files.

Solution One

Modify the "vs installation directory \vc\vcwizards\default.vcxproj" This file, (which is actually an XML file)

As my directory is "D:\Program Files\Microsoft Visual Studio 11.0\vc\vcwizards\default.vcxproj"

If the directory I want to add is "D:\Program Files\Microsoft Visual Studio 11.0\vc\wtl\include";

Open the file with a text editor, navigate to the end of the file, and insert the following before </Project>

  <PropertyGroup>    <includepath>$ (VCInstallDir) \wtl\include;$ (Includepath) </includepath</propertygroup>         

$ (VCInstallDir) \wtl\include; it's the directory you need to add. $ (VCInstallDir) is the environment variable in VS ("D:\Program Files\Microsoft Visual Studio 11.0\VC" on My Computer), which represents the installation directory of the VC. $ (includepath) is the path that represents the original. There are actually four paths that are eventually obtained.

If you need to add the path to the Lib file. Format is <LibraryPath></LibraryPath>

After adding a new project, you can see that the catalog has been added in the project properties. VS2010 is done the same way, but the directory is different.

Solution II

This method is combined with the modification method on the StackOverflow website mentioned at the beginning.

Still modify the "vs installation directory \vc\vcwizards\default.vcxproj" This file, except where the change here, with a text editor to open the file, look for "$ (userrootdir) \ microsoft.cpp.$ (Platform). User.props "This paragraph,

Actually, this is the file that pointed to my computer C:\Users\HwangBae\AppData\Local\Microsoft\MSBuild\v4.0\ Microsoft.Cpp.Win32.user.props; Here I think, for VS2010 and VS2012 to specify a different file,

Replace "$ (Userrootdir) \microsoft.cpp.$ (Platform). User.props" with "$ (userrootdir) \vc11\microsoft.cpp.$ ( Platform). User.props ".

Then two folders are created under the C:\Users\HwangBae\AppData\Local\Microsoft\MSBuild\v4.0 directory, named VC10 and VC11, and then Microsoft.Cpp.Win32.user.props copied to both folders, and then except the two folders can be deleted files, and other file vs will be automatically recreated in those two folders;

Then edit the Microsoft.Cpp.Win32.user.props file and Insert the same code under the <Project> node by following the steps in method one. The same substitutions are also made under the VS2010 directory. That's it for the finished. Test without any problems.

Summarize the differences between the two methods, when the method is modified, only the new project is valid, the project created before the modification is not valid, and the method is valid for the previously created project. Which method is more suitable for everyone's own choice.

[Reprint] Add a default include path method for Visual Studio

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.