2011-08-25 93 views
1

我有一个使用IBPP访问firebird数据库的C++项目。我只是通过在我的项目中包含文件“all_in_one.cpp”来做到这一点,并且都与VS6(是的,我还有其中一些)和VS2008都很好。使用VS2010编译IBPP - 链接问题

现在我正在考虑使用VS2010。它正在编译好,但没有链接。我知道VS2010附带了STL的新实现,链接问题显然在STL的周围。

我曾尝试用VS2010创建一个新项目,只是添加all_in_one.cpp文件。这是一个简单的项目,不包含任何其他内容,并且仍然无法链接相同的缺失符号。我无法弄清楚什么是缺失的,不正确的。我已经尝试链接到VS2008中的相同库(包括路径)。到目前为止没有任何工作。

下面是错误:

all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) struct std::_Smanip<__int64> __cdecl std::setw(__int64)" ([email protected]@@[email protected][email protected]@[email protected]) referenced in function "public: char const * __thiscall IBPP::DBKey::AsString(void)const " ([email protected]@[email protected]@QBEPBDXZ) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base12::_Orphan_all(void)" ([email protected][email protected]@@QAEXXZ) referenced in function "public: class std::vector<double,class std::allocator<double> > & __thiscall std::vector<double,class std::allocator<double> >::operator=(class std::vector<double,class std::allocator<double> > const &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@@Z) 
all_in_one.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" ([email protected]?$[email protected][email protected]@[email protected]@@[email protected]@UAEXXZ) 
all_in_one.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@UAEXXZ) 
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::showmanyc(void)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@MAE_JXZ) 
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::xsgetn(char *,__int64)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) 
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::xsputn(char const *,__int64)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) 
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::setbuf(char *,__int64)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]) 
all_in_one.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) __int64 const std::_BADOFF" ([email protected]@@3_JB) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xlength_error(char const *)" ([email protected]@@[email protected]) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xlen(void)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@QBEXXZ) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xout_of_range(char const *)" ([email protected]@@[email protected]) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xran(void)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@QBEXXZ) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::~_Container_base12(void)" ([email protected]@@[email protected]) referenced in function [email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@Z$0 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::_Container_base12(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall std::_String_val<char,class std::allocator<char> >::_String_val<char,class std::allocator<char> >(class std::allocator<char>)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@Z) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: struct std::_Iterator_base12 * * __thiscall std::_Container_base12::_Getpfirst(void)const " ([email protected][email protected]@@[email protected]@XZ) referenced in function "protected: void __thiscall std::vector<class ibpp_internals::TransactionImpl *,class std::allocator<class ibpp_internals::TransactionImpl *> >::_Orphan_range(class ibpp_internals::TransactionImpl * *,class ibpp_internals::TransactionImpl * *)const " ([email protected][email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@@[email protected]@[email protected][email protected]@[email protected]) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::ios_base::width(__int64)" ([email protected][email protected]@@[email protected]) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" ([email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected]) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" ([email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected]) 
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::ios_base::width(void)const " ([email protected][email protected]@@QBE_JXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" ([email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected]) 

回答

1

看来你的库/ DLL是出口一些模板/ STL的东西。

STL在不同的编译器版本中不是二进制兼容的。

如果涉及STL /模板,则需要使用相同的编译器/链接器/位来编译和链接DLL/EXE。

+0

正如我所说,我已经创建了一个全新的项目,只是添加了cpp文件。所有正在编译的VS2010中,这是使用默认安装安装的。我没有链接到任何特定的东西(除了VS2010将使用的默认库)。现在,在同一台PC上也有VS2008和VC6,这些都是以前安装的。但是,由于VS2010最后安装了,我会认为这不会被其他人“打扰”。此外,这个项目是一个简单的控制台应用程序,没有花哨,没有库,我甚至没有调用代码,只是编译到项目中。 –

+0

原来这是正确的问题。其中一个项目属性指向错误的库,仍在VS2008路径上。我将不得不找出它在哪里作为默认使用... –

0

从构建中删除all_in_one.cpp,并使用核心中的其他文件构建库。

+0

没有工作。我得到了相同的外部解析列表。 –

0

关于上述错误列表中的链接器错误10和11,我有以下解决方案 (可能会修复所有错误)。

右键单击解决方案资源管理器中的项目并选择“属性”,打开项目的属性页。

里面的“属性页” -window:

--> open "Configuration Properties" from left menu 
    --> select "VC++ Directories" on the left 
     --> go to "Library Directories" on the right 
      --> the corresponding string should contain a sub-string like 
       "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib" 
       --> replace "9.0" by "10.0" 

进行更改工作“重新”构建解决方案(也许是先清理解决方案)。