简体   繁体   English

它显示错误消息无法在我的Visual c ++中创建OCI环境

[英]It shows error message Cannot create OCI environment in my Visual c++

I am using Microsoft Visualstudio2015, i am trying to run c++ program using OCI functions, but my program terminating. 我正在使用Microsoft Visualstudio2015,正在尝试使用OCI函数运行c ++程序,但是我的程序终止了。

I set ocilib path in my visual studio and it starting successfully, but i got message initialising failed in my log file 我在视觉工作室中设置了ocilib路径,并且成功启动,但是在日志文件中消息初始化失败

#include "ocilib.h"      

ofstream LogFile;        
LogFile.open("logfile.txt");
void err_handler(OCI_Error *err)
{
if(OCI_ErrorGetType(err) == OCI_ERR_ORACLE)
{
const mtext* sql =OCI_GetSql(OCI_ErrorGetStatement(err));
if(sql != NULL)
{
  LogFile<<"ERROR - SQL : "<<sql<<"\n";
}
}

LogFile<<"ERROR - MSG : "<<OCI_ErrorGetString(err)<<endl;
++nbr_error;
}


if(!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
{
 LogFile<<"ERROR - Initialise failed\n";
 exit(1);
}

After running the program It shows ERROR - MSG: Cannot create OCI environment Program terminating, 运行该程序后,它显示错误-MSG:无法创建OCI环境程序终止,

what i supposed to do. 我应该怎么办。

Download instantclient-basic and instantclient-sdk-windows from http://www.oracle.com/technetwork/cn/topics/winsoft-085727.html . http://www.oracle.com/technetwork/cn/topics/winsoft-085727.html下载instantclient-basic和Instantclient-sdk-windows。

You should choose the x86 or the x64 version based on your program. 您应该根据程序选择x86或x64版本。 And then decompress and merge them to one folder. 然后解压缩并将它们合并到一个文件夹。

In your program, OCI_Initialize(err_handler, the_folder , OCI_ENV_DEFAULT) 在您的程序中,OCI_Initialize(err_handler, the_folder ,OCI_ENV_DEFAULT)

Re-check your OCILIB path in Environment variables, for example:- 重新检查环境变量中的OCILIB路径,例如:

 Copy ocilib\include\ocilib.h : to a folder listed in the compiler headers folders
 Copy ocilib\lib32 |64\ocilib [x].Lib : to a folder listed in the linker libraries folders
 Copy ocilib\lib32|64\ocilib [x]. Dll : to a folder included in the PATH environment variable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM