Buenas! Estaba queriendo conectar a una base de datos sql server, y descargué la librería SQLAPI++, el problema es que al intentar linkearla me da error. Les dejo el código :
Código:
include <iostream>
#include "C:\....\SQLAPI.h"
using namespace std;
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(
"GunzDB", // database name
"sa", // user name
"btf870621345", // password
SA_SQLServer_Client);
cout << " We are connected ! " << endl;
// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect();
cout << " We are disconnected ! " << endl;
}
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
cout << (const char*)(x.ErrText()) << endl;
}
return 0;
}
Intenté también poniendo #include "SQLAPI.h"
#include <SQLAPI.h> y todas las variantes, y nada. También fui a build options, agregué en linker settings la librería (sqlapi.lib), y en search directories la carpeta en donde se encuentra el .lib.
El error es :
||=== Build: Debug in Programa03 (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `main':|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|8|undefined reference to `SAConnection::SAConnection()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::SAString(char const*)'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::SAString(char const*)'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::SAString(char const*)'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAConnection::Connect(SAString const&, SAString const&, SAString const&, eSAClient, void (*)(SAConnection&, eSAConnectionHandlerType))'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|26|undefined reference to `SAConnection::Disconnect()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|48|undefined reference to `SAConnection::~SAConnection()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|20|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|45|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|39|undefined reference to `SAConnection::Rollback()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|45|undefined reference to `SAException::ErrText() const'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|45|undefined reference to `SAString::operator char const*() const'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|45|undefined reference to `SAString::~SAString()'|
C:\Users\Diego\Desktop\C\workspace\Programa03\main .cpp|48|undefined reference to `SAConnection::~SAConnection()'|
||=== Build failed: 19 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Alguna solución? Gracias desde ahora:D