error while loading shared libraries: libsqlora8-2.3.so.0

[root@licheng ~]# gcc -lsqlora8 ./test.c -o test
最后一次编译成功,但是执行却出现错误

首先以root用户执行
[root@licheng ~]# ./test
./test: error while loading shared libraries: libsqlora8-2.3.so.0: cannot open shared object file: No such file or directory

再以oracle用户执行
[oracle@licheng ~]$ ./test
./test: error while loading shared libraries: libsqlora8-2.3.so.0: cannot open shared object file: No such file or directory

请教牛人这是怎么回事?


那就表示系統不知道xxx.so 放在哪個目錄下。

這個時候就要在/etc/ld.so.conf中加入xxx.so所在的目錄。

 一般而言,有很多so檔會在/usr/local/lib這個目錄下,所以在/etc/ld.so.conf中加入/usr/local/lib這一行,可以解決此問題。

test.c内容如下:
#include <stdio.h>
#include <stdlib.h>
#include "sqlora.h"
static CONST char * _defuser="hr/hr@mydata";
int main(int argc,char **argv)
{
sqlo_db_handle_t dbh;
CONST char * cstr = _defuser;
char server_version[100];
if (SQLO_SUCCESS!= sqlo_init(SQLO_OFF,1,100))
{
printf("Failed to init libsqlora8\n");
return EXIT_FAILURE;
}
if (SQLO_SUCCESS != sqlo_connect(&dbh,cstr))
{
printf("Cannot login with %s \n",cstr);
return EXIT_FAILURE;
}
if (SQLO_SUCCESS != sqlo_server_version(dbh,server_version,sizeof(server_version)))
{
printf("Failed to get the server version: %s\n", sqlo_geterror(dbh));
return EXIT_FAILURE;
}
printf("Connected to:\n%s\n\n", server_version);
}

 

执行
[root@licheng ~]# echo '/usr/local/lib' >> /etc/ld.so.conf
就可以了

將 /etc/ld.so.conf存檔後,還要執行「/sbin/ldconfig –v」來更新一下才會生效。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值