VS10 "Дополнительные каталоги включения" указывают на VS9 Включает
Я установил VS10 параллельно с VS9 и создал очень простое приложение, используя его:
#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;
}
Это породило ряд очень странных ошибок компилятора:
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 <vector>
и т.д., файлы VS9 #include
-ed. Это, в свою очередь, я предполагаю, потому что $(IncludePath)
переменная определяется как:
Когда я пошел в Инструменты> Параметры> Проекты и решения> Каталоги VC++, чтобы изменить глобальные настройки для этого и всех будущих проектов, я обнаружил несчастную правду:
Итак, как мне изменить этот глобальный параметр? Установщик явно установил его неправильно.
1 ответ
Вот шаги, чтобы изменить файл настроек через интерфейс:
Откройте менеджер свойств, нажав на View.Property Manager.
Разверните узел проекта, а затем узлы Configuration|Platform, вы увидите файл "Microsoft.cpp..users" для каждой платформы Configuration | Это файлы для глобальных настроек, аналогичные старым каталогам tools/Options/VC++.
Выберите "Microsoft.cpp..users", щелкните правой кнопкой мыши и откройте окно страницы свойств.
В окне страницы свойств нажмите "Каталоги VC++" (например) на левой панели, добавьте новые пути для каталогов, например "Включить каталоги". разделенные точкой с запятой
Обязательно сохраните настройки перед выключением Visual Studio.
Перезапустите Visual Studio, и новые настройки вступят в силу.
Если вы хотите изменить настройки только для определенного проекта, вы можете щелкнуть правой кнопкой мыши на проекте и открыть страницу свойств. Измените настройки для "Каталоги VC++", эти настройки будут сохранены в файле проекта.