2010-08-19 65 views
1

我安裝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)變量定義爲: alt text

當我去工具>選項>項目和解決方案> VC++目錄改變全局設置,這和所有未來的項目,我發現了一個不幸的事實:

alt text

那麼,如何改變這一全局設置?安裝人員將其設置不正確。

回答

6

下面是更改設置文件通過用戶界面的步驟:

  • 點擊View.Property管理器中打開了物業經理。

  • 展開項目節點,然後在Configuration | Platform節點上,您將看到每個Configuration | Platform的「Microsoft.cpp..users」文件。這些是全局設置的文件,類似於舊的工具/選項/ VC++目錄。

  • 多選「Microsoft.cpp..users」,點擊右鍵,彈出屬性頁窗口

  • 在屬性頁窗口中,點擊「VC++目錄」(例如)在左窗格中,爲諸如「包含目錄」之類的目錄添加新路徑。用分號分隔

  • 確保在關閉Visual Studio之前保存設置。

  • 重新啓動Visual Studio,新設置將生效。

如果您只想更改特定項目的設置,您可以右鍵單擊該項目並調出屬性頁面。更改「VC++目錄」的設置,這些設置將被保存到項目文件中。

+0

謝謝。我沒有點擊'?'獲取更多信息,但最初未能看到說明。一定需要咖啡。無論如何,當你輸入你的回答時,我是這樣做的,而且確實有效。現在下一個問題:爲什麼他們需要使這個不必要的複雜? (修辭) – 2010-08-19 22:26:19