用VS2010编译IBPP - 链接问题

时间:2011-08-25 09:36:32

标签: visual-studio-2010 visual-c++ firebird

我有一个使用IBPP访问firebird数据库的C ++项目。我只是通过在我的项目中包含文件“all_in_one.cpp”来完成它,并且VS6(是的,我还有一些)和VS2008都很顺利。

现在我正在考虑使用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)" (__imp_?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z) referenced in function "public: char const * __thiscall IBPP::DBKey::AsString(void)const " (?AsString@DBKey@IBPP@@QBEPBDXZ)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base12::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base12@std@@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 &)" (??4?$vector@NV?$allocator@N@std@@@std@@QAEAAV01@ABV01@@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)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@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)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@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)" (?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@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)" (?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE_JPAD_J@Z)
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)" (?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE_JPBD_J@Z)
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)" (?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PAD_J@Z)
all_in_one.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) __int64 const std::_BADOFF" (__imp_?_BADOFF@std@@3_JB)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xlength_error(char const *)" (__imp_?_Xlength_error@std@@YAXPBD@Z) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xlen(void)const " (?_Xlen@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEXXZ)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xout_of_range(char const *)" (__imp_?_Xout_of_range@std@@YAXPBD@Z) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xran(void)const " (?_Xran@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEXXZ)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::~_Container_base12(void)" (__imp_??1_Container_base12@std@@QAE@XZ) referenced in function __unwindfunclet$??0?$_String_val@DV?$allocator@D@std@@@std@@QAE@V?$allocator@D@1@@Z$0
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::_Container_base12(void)" (__imp_??0_Container_base12@std@@QAE@XZ) referenced in function "public: __thiscall std::_String_val<char,class std::allocator<char> >::_String_val<char,class std::allocator<char> >(class std::allocator<char>)" (??0?$_String_val@DV?$allocator@D@std@@@std@@QAE@V?$allocator@D@1@@Z)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: struct std::_Iterator_base12 * * __thiscall std::_Container_base12::_Getpfirst(void)const " (__imp_?_Getpfirst@_Container_base12@std@@QBEPAPAU_Iterator_base12@2@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 " (?_Orphan_range@?$vector@PAVTransactionImpl@ibpp_internals@@V?$allocator@PAVTransactionImpl@ibpp_internals@@@std@@@std@@IBEXPAPAVTransactionImpl@ibpp_internals@@0@Z)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::ios_base::width(__int64)" (__imp_?width@ios_base@std@@QAE_J_J@Z) 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 *)" (??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)
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)" (__imp_?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE_JPBD_J@Z) 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 *)" (??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::ios_base::width(void)const " (__imp_?width@ios_base@std@@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 *)" (??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)

3 个答案:

答案 0 :(得分:1)

您的库/ DLL似乎正在导出一些模板化/ STL内容。

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

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

答案 1 :(得分:0)

从构建中删除all_in_one.cpp并使用core中的其他文件来构建库。

答案 2 :(得分:0)

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

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

在“物业页面”内 - 窗口:

-->  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"

使更改正常“重新”构建您的解决方案(可能首先清理您的解决方案)。