下面是我的简单测试代码。我已经编译它使用
$gcc test.c -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI -locilib
它编译成功,但是当我运行它时显示错误-
./a.out: error while loading shared libraries: libocilib.so.3: cannot open shared object file: No such file or directory
我在我的 bashrc 文件中添加了以下路径-
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib
export ORACLE_HOME=/usr/lib/oracle/11.2/client
export TNS_ADMIN=/usr/lib/oracle/11.2/client/network/admin
#include "ocilib.h"
int main(void)
{
OCI_Connection *cn;
if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
return EXIT_FAILURE;
cn = OCI_ConnectionCreate("sam", "SYSTEM", "oracle", 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;
}
我不知道是什么原因。请帮忙。我对linux知之甚少。