【发布时间】:2014-03-30 11:11:35
【问题描述】:
Total Newbie 使用 Visual Studio 2010 试用 SQLAPI,底部的代码是他们提供的确切示例,所以我相信代码没有问题。但是当我尝试构建它时,它只是一直显示 LNK2019。
这些是错误:
错误 LNK2019:函数 __catch$_main$0 中引用的未解析外部符号“public: virtual __thiscall SAConnection::~SAConnection(void)”(??1SAConnection@@UAE@XZ)
错误 LNK2019:函数 __catch$_main$0 中引用的未解析外部符号“public: __thiscall SAString::operator char const *(void)const”(??BSAString@@QBEPBDXZ)
错误 LNK2019:函数 __catch$_main$0 中引用了无法解析的外部符号“public: class SAString __thiscall SAException::ErrText(void)const” (?ErrText@SAException@@QBE?AVSAString@@XZ)
错误 LNK2019:函数 __catch$_main$0 中引用的未解析外部符号“public: void __thiscall SAConnection::Rollback(void)”(?Rollback@SAConnection@@QAEXXZ)
错误 LNK2019:函数 _main 中引用了无法解析的外部符号“public: void __thiscall SAConnection::Disconnect(void)”(?Disconnect@SAConnection@@QAEXXZ)
错误 LNK2019:函数 _main 中引用的未解析外部符号“public: __thiscall SAString::~SAString(void)”(??1SAString@@QAE@XZ)
错误 LNK2019:无法解析的外部符号“public: void _thiscall SAConnection::Connect(class SAString const &,class SAString const &,class SAString const &,enum eSAClient,void (_cdecl*) (class SAConnection &,enum eSAConnectionHandlerType))" (?Connect@SAConnection@@QAEXABVSAString@@00W4eSAClient@@P6AXAAV1@W4eSAConnectionHandlerType@@@Z@Z) 在函数_main中引用
错误 LNK2019:函数 _main 中引用了无法解析的外部符号“public: __thiscall SAString::SAString(char const *)”(??0SAString@@QAE@PBD@Z)
错误 LNK2019:函数 _main 中引用的未解析的外部符号“public: __thiscall SAConnection::SAConnection(void)”(??0SAConnection@@QAE@XZ)
我在项目属性中的 C/C++ 和链接器的附加包含目录中添加了库说明。那么,我错过了什么?
提前致谢。
我正在尝试构建的代码:
int main(int argc, char* argv[])
{
SAConnection con; // create connection object
try
{
// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC
con.Connect(
"DIGITALZONE\MSSQL", // database name
"DIGITALZONE\Digital10", // user name
"", // password
SA_Oracle_Client);
printf("We are connected!\n");
// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect();
printf("We are disconnected!\n");
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
printf("%s\n", (const char*)x.ErrText());
}
return 0;
【问题讨论】:
-
你确定在你的链接器设置中有 sqlApi.lib 文件吗?
标签: c++ c visual-studio-2010 linker