首页 新闻 搜索 专区 学院

在unix环境调用sqlapi++ brary库怎么编译

0
悬赏园豆:10 [已解决问题] 解决于 2011-11-03 08:48

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

Kahuna的主页 Kahuna | 初学一级 | 园豆:191
提问于:2011-10-31 13:12
< >
分享
最佳答案
0

ld出错的信息提示,libsqlapi.so和你机器的架构不配套,因此解决方法是安装个和你机器配套的so库,或自己编译一个

收获园豆:10
2012 | 高人七级 |园豆:20846 | 2011-11-01 13:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册