2013-07-02 56 views
0

我正在一個大項目從Visual Studio 2008(平臺工具集V90)到Visual Studio 2010(平臺工具集V100)移動從Visual Studio 2008中使用靜態庫與Visual Studio 2010

該項目依靠庫使用v90工具集進行編譯。這個庫在很大程度上是用C語言編寫的,在一些地方使用了std:string。不幸的是這種用法阻止我與庫鏈接編譯由於工具箱的變化

我從錯誤中刪除的庫名:

: error LNK2001: 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) 
: error LNK2001: 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]) 
: error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
: error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int const std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::npos" ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@2IB) 
: error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
: error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(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) 
: error LNK2001: 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) 
: error LNK2001: 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]) 

有什麼我能做的事編譯下這個庫平臺工具集v100?該庫是專有的,所以我無法獲取源代碼並重新編譯自己。

+1

聯繫供應商,看看他們是否有用VC++編譯的庫的版本10 –

+0

我認爲你唯一能做到的方法就是在VC2008中製作一個包含靜態庫的DLL,並提供一個C風格的界面,從你需要的任何功能。然後,您需要爲2008和2010分發運行時。 – Pete

+0

如果運行時靜態鏈接到dll,則@Pete 2008運行時可能不是必需的。 –

回答

0

如果得到一個VC2010版本的庫是不可能的,那麼你將需要使用VS2008構建一個DLL,它提供了VS2008靜態庫中的功能。

您可能無法將C++鏈接用於此DLL,並且肯定無法在DLL和主應用程序之間直接傳遞std :: string。這是因爲內存佈局/接口不同,最終會導致ODR違規和崩潰等(即使您沒有大量錯誤,您甚至可以編譯/鏈接它)。因此,您需要製作一個C風格的API,該風格的API可供您的主VS2010應用程序使用。字符串將需要作爲c風格const char*const wchar_t*字符串或其他一些結構/不透明指針傳遞。

如果您可以通過靜態鏈接到VS2008運行庫的方式構建DLL,那麼它將簡化部署,否則您將需要以您選擇的任何方式將VS2008和VS2010運行時與應用程序安裝程序一起分發。

相關問題