VS10“附加包含目录"指向 VS9 包括 [英] VS10 "Additional Include Directories" Point to VS9 Includes

查看:32
本文介绍了VS10“附加包含目录"指向 VS9 包括的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我同时安装了 VS10 和 VS9,并使用它创建了一个非常简单的应用程序:

I installed VS10 side-by-side with VS9 and created a very simple application using it:

#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

class A
{
};
class B : public A
{
};

A* get_a() { return new B; }

int main()
{
    vector<A*> a_list;
    vector<B*> b_list;

    generate_n(back_inserter(a_list), 10, get_a);

    return 0;
}

这产生了许多非常奇怪的编译器错误:

This generated a number of very odd compiler errors:

1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " (__imp_?_Orphan_all@_Container_base_secure@std@@QBEXXZ) referenced in function "protected: void __thiscall std::vector<class A *,class std::allocator<class A *> >::_Tidy(void)" (?_Tidy@?$vector@PAVA@@V?$allocator@PAVA@@@std@@@std@@IAEXXZ)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (__imp_??1_Container_base_secure@std@@QAE@XZ) referenced in function "protected: __thiscall std::_Container_base_aux_alloc_empty<class std::allocator<class A *> >::~_Container_base_aux_alloc_empty<class std::allocator<class A *> >(void)" (??1?$_Container_base_aux_alloc_empty@V?$allocator@PAVA@@@std@@@std@@IAE@XZ)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (__imp_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) referenced in function "protected: static void __cdecl std::vector<class A *,class std::allocator<class A *> >::_Xlen(void)" (?_Xlen@?$vector@PAVA@@V?$allocator@PAVA@@@std@@@std@@KAXXZ)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) referenced in function "protected: staticvoid __cdecl std::vector<class A *,class std::allocator<class A *> >::_Xlen(void)" (?_Xlen@?$vector@PAVA@@V?$allocator@PAVA@@@std@@@std@@KAXXZ)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (__imp_?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) referenced in function "public: virtual char const * __thiscall std::logic_error::what(void)const " (?what@logic_error@std@@UBEPBDXZ)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (__imp_??0_Container_base_secure@std@@QAE@XZ) referenced in function "protected: __thiscall std::_Container_base_aux_alloc_empty<class std::allocator<class A *> >::_Container_base_aux_alloc_empty<class std::allocator<class A *> >(class std::allocator<class A *>)" (??0?$_Container_base_aux_alloc_empty@V?$allocator@PAVA@@@std@@@std@@IAE@V?$allocator@PAVA@@@1@@Z)

...这让我摸不着头脑一段时间,直到我发现错误的标题被 #include-ed.与 VS10 版本的 等不同,VS9 文件是 #include-ed.反过来,我认为这是因为 $(IncludePath) 变量定义为:

...which made me scratch my head for some time, until I discovered that the wrong headers were being #include-ed. Instead of the VS10 version of <vector> etc, the VS9 files are #include-ed. This, in turn, I assume is because the $(IncludePath) variable is defined as:

当我去工具>选项>项目和解决方案>VC++目录更改这个和所有未来项目的全局设置时,我发现了一个令人不快的事实:

When I went to Tools>Options>Projects and Solutions>VC++ Directories to change the global setting for this and all future projects, I discovered an unhappy truth:

那么我该如何更改这个全局设置呢?安装程序显然设置不正确.

So how do I change this global setting? The installer clearly set it incorrectly.

推荐答案

以下是通过 UI 更改设置文件的步骤:

Here are the steps to change the settings file through UI:

  • 点击 View.Property Manager 打开 Property Manager.

  • Open up property manager by clicking on View.Property Manager.

展开项目节点,然后展开配置|平台节点,您将看到每个配置|平台的Microsoft.cpp..users"文件.这些是全局设置的文件,类似于旧的工具/选项/VC++ 目录.

Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp..users" file for each Configuration|Platform. These are the files for the global settings, similar to the old tools/Options/VC++ Directories.

多选Microsoft.cpp..users",右击弹出属性页窗口

Multi-Select "Microsoft.cpp..users", right click and bring up the property page window

在属性页窗口中,单击左窗格中的VC++ 目录"(例如),为目录添加新路径,例如包含目录".用分号分隔

In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by semicolons

确保在关闭 Visual Studio 之前保存设置.

Make sure to save the settings before shutting down Visual Studio.

重新启动 Visual Studio,新设置将生效.

Re-launch Visual Studio and the new settings will be in effect.

如果您只想更改特定项目的设置,您可以右键单击该项目并调出属性页面.更改VC++目录"的设置,这些设置将持久化到项目文件中.

If you would like to only change the settings for a specific project, you can right click on the project and bring up the property page. Change the settings for "VC++ Directories", these settings will be persisted to the project file.

这篇关于VS10“附加包含目录"指向 VS9 包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆