我安裝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 " ([email protected][email protected]@@QBEXXZ) referenced in function "protected: void __thiscall std::vector<class A *,class std::allocator<class A *> >::_Tidy(void)" ([email protected][email protected]@@[email protected]@@@[email protected]@@[email protected]@IAEXXZ)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" ([email protected]@@[email protected]) 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)" ([email protected][email protected]@@@[email protected]@@[email protected]@[email protected])
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "protected: static void __cdecl std::vector<class A *,class std::allocator<class A *> >::_Xlen(void)" ([email protected][email protected]@@[email protected]@@@[email protected]@@[email protected]@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 *)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "protected: staticvoid __cdecl std::vector<class A *,class std::allocator<class A *> >::_Xlen(void)" ([email protected][email protected]@@[email protected]@@@[email protected]@@[email protected]@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 &)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@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 &)" ([email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@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 " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@QBEPBDXZ) referenced in function "public: virtual char const * __thiscall std::logic_error::what(void)const " ([email protected][email protected]@@UBEPBDXZ)
1>hacks_vs10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" ([email protected]@@[email protected]) 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 *>)" ([email protected][email protected]@@@[email protected]@@[email protected]@[email protected][email protected]@@@[email protected]@Z)
......這讓我撓了腦袋一段時間,直到我發現錯誤的標題爲#include
-ed。 VS12版本的<vector>
等,VS9文件是#include
-ed。這反過來,我認爲是因爲$(IncludePath)
變量定義爲:
當我去工具>選項>項目和解決方案> VC++目錄改變全局設置,這和所有未來的項目,我發現了一個不幸的事實:
那麼,如何改變這一全局設置?安裝人員將其設置不正確。
謝謝。我沒有點擊'?'獲取更多信息,但最初未能看到說明。一定需要咖啡。無論如何,當你輸入你的回答時,我是這樣做的,而且確實有效。現在下一個問題:爲什麼他們需要使這個不必要的複雜? (修辭) – 2010-08-19 22:26:19