问题编译OCILIB OCI包装库 [英] Problems Compiling OCILIB OCI Wrapper Library

查看:276
本文介绍了问题编译OCILIB OCI包装库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译演示在 ocilib3.8.1 /演示。成功安装 OCILIB 库后,我再编译如下演示源conn.c:

I'm trying to compile demo in ocilib3.8.1/demo. After successfully installing the ocilib library, I then compile demo source conn.c below :

#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);

    printf("Server major    version : %i\n",   OCI_GetServerMajorVersion(cn));
    printf("Server minor    version : %i\n",   OCI_GetServerMinorVersion(cn));
    printf("Server revision version : %i\n\n", OCI_GetServerRevisionVersion(cn));
    printf("Connection      version : %i\n\n", OCI_GetVersionConnection(cn));

    OCI_Cleanup();

    return EXIT_SUCCESS;
}

编译使用gcc:

Compile using gcc :

$gcc -Wall conn.c -o conn.o -I/usr/local/include \
    -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI

错误:

$ gcc -Wall conn.c -o conn.o -I/usr/local/include \
    -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI
/tmp/ccMgFQri.o: In function `main':
conn.c:(.text+0x26): undefined reference to `OCI_Initialize'
conn.c:(.text+0x4f): undefined reference to `OCI_ConnectionCreate'
conn.c:(.text+0x63): undefined reference to `OCI_GetServerMajorVersion'
conn.c:(.text+0x82): undefined reference to `OCI_GetServerMinorVersion'
conn.c:(.text+0xa1): undefined reference to `OCI_GetServerRevisionVersion'
conn.c:(.text+0xc0): undefined reference to `OCI_GetVersionConnection'
conn.c:(.text+0xd6): undefined reference to `OCI_Cleanup'
collect2: ld returned 1 exit status

我使用的是RedHat EL5,gcc版本3.4.6 20060404(红帽3.4.6-4),即时客户机发行10.2.0.5.0。

I'm using redhat el5, gcc version 3.4.6 20060404 (Red Hat 3.4.6-4), instant client Release 10.2.0.5.0.

感谢您的帮助。我在linux下编程的新手..

Thanks for help. I'm newbies in linux programming ..

推荐答案

您必须对OCILIB联系!

you have to link against ocilib !

添加-locilib命令行:)

add "-locilib" to the command line :)

这篇关于问题编译OCILIB OCI包装库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆