1
votes

Total Newbie Using Visual Studio 2010 to try out SQLAPI, the code at the bottom is the exact example provided by them so there is no problem in the code I believe. But it just Keeps showing LNK2019 when I tries to build it.

These are the errors:


error LNK2019: unresolved external symbol "public: virtual __thiscall SAConnection::~SAConnection(void)" (??1SAConnection@@UAE@XZ) referenced in function __catch$_main$0

error LNK2019: unresolved external symbol "public: __thiscall SAString::operator char const *(void)const " (??BSAString@@QBEPBDXZ) referenced in function __catch$_main$0

error LNK2019: unresolved external symbol "public: class SAString __thiscall SAException::ErrText(void)const " (?ErrText@SAException@@QBE?AVSAString@@XZ) referenced in function __catch$_main$0

error LNK2019: unresolved external symbol "public: void __thiscall SAConnection::Rollback(void)" (?Rollback@SAConnection@@QAEXXZ) referenced in function __catch$_main$0

error LNK2019: unresolved external symbol "public: void __thiscall SAConnection::Disconnect(void)" (?Disconnect@SAConnection@@QAEXXZ) referenced in function _main

error LNK2019: unresolved external symbol "public: __thiscall SAString::~SAString(void)" (??1SAString@@QAE@XZ) referenced in function _main

error LNK2019: unresolved external symbol "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) referenced in function _main

error LNK2019: unresolved external symbol "public: __thiscall SAString::SAString(char const *)" (??0SAString@@QAE@PBD@Z) referenced in function _main

error LNK2019: unresolved external symbol "public: __thiscall SAConnection::SAConnection(void)" (??0SAConnection@@QAE@XZ) referenced in function _main


I did the adding library directions at additional Include Directories in both C/C++ and Linker in Project Properties. So, What am I missing?

Thanks in advance.

Code I'm Trying to build:

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;
1
are u sure to have the sqlApi.lib file in your linker settings ?alexbuisson

1 Answers

3
votes

Specify the sqlapi.lib in additional dependencies of the project properties->linker tab.