hp-unix环境下我把sqlapi++ brary 官方网站上这个库下了下来
弄了个简单的程序测试下怎么用...
#include<stdio.h> // for printftest1.cpp
#include<stdlib.h>
#include<iostream>
#include <SQLAPI.h> // main SQLAPI++ header
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,Oracle
// SQLServer, InterBase, SQLBase and ODBC
con.Connect("10.70.212.18:1521@opENVIEW","ipnms","ipadmin",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;
}
//###########################################################################################################
hp-unix环境下g++ -L/home/cjwtest/SQLAPI/lib cjw_test1.cpp -ldl -lsqlapi -I/home/cjwtest/SQLAPI/include -o cjw_test1
ld: (Warning) Ignore library /home/cjwtest/SQLAPI/lib/libsqlapi.so with bad machine type 3
ld: (Warning) Ignore library /home/cjwtest/SQLAPI/lib/libsqlapi.a with bad machine type 3
ld: Mismatched ABI for -lsqlapi, found /home/cjwtest/SQLAPI/lib/libsqlapi.so
Fatal error.
collect2: ld returned 1 exit status
ld出错的信息提示,libsqlapi.so和你机器的架构不配套,因此解决方法是安装个和你机器配套的so库,或自己编译一个