c++ - 尝试使用 SQLAPI 时出现错误 LNK2019(Visual Studio 2010)

标签 c++ c visual-studio-2010 linker

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:未解析的外部符号“public: class SAString __thiscall SAException::ErrText(void)const” (?ErrText@SAException@@QBE?AVSAString@@XZ) 在函数 __catch$_main$0 中引用

错误 LNK2019:函数 __catch$_main$0 中引用了未解析的外部符号“public: void __thiscall SAConnection::Rollback(void)” (?Rollback@SAConnection@@QAEXXZ)

错误 LNK2019:未解析的外部符号“public: void __thiscall SAConnection::Disconnect(void)” (?Disconnect@SAConnection@@QAEXXZ) 在函数 _main 中引用

错误 LNK2019:未解析的外部符号“public: __thiscall SAString::~SAString(void)” (??1SAString@@QAE@XZ) 在函数 _main 中引用

错误 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:未解析的外部符号“public: __thiscall SAString::SAString(char const *)” (??0SAString@@QAE@PBD@Z) 在函数 _main 中引用

错误 LNK2019:未解析的外部符号“public: __thiscall SAConnection::SAConnection(void)” (??0SAConnection@@QAE@XZ) 在函数 _main 中引用


我在项目属性中的 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++ - 尝试使用 SQLAPI 时出现错误 LNK2019(Visual Studio 2010),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22061468/

相关文章:

c++ - 如何使用 C++ 控制台应用程序返回一个大数字

c++ - OpenGL 游戏在 Win7 中运行良好,在 Windows 8 中下降到 5fps?

c# - 用于检查方法内部是否有 "+="的正则表达式

c++ - 在 C++ 中读取 txt 文件时跳过特定内容

c++ - 将 CImg 库与 Qt 一起使用可以更快地调整图像大小。值得挖掘吗?

c - 使用有限的工具、没有数组和库函数评估简单的数学表达式

c - 将 void * 缓冲区用作 char * 以外的任何缓冲区是否合法?

c++ - 使用 libdc1394 在 Pointgrey Firefly MV 上输出频闪信号

c++ - GCC不喜欢使用匿名命名空间转发声明来结交 friend ,但是MSVC愿意。什么?

c++ - 从 .txt 文件中读取 UNICODE 字符并将它们输出到控制台