C++用OTL链接Oracle 11g远程数据库出现的有关问题求解决
C++用OTL链接Oracle 11g远程数据库出现的问题求解决
程序如下,很简单
#include <iostream>
using namespace std;
#include <stdio.h>
#define OTL_ORA11G_R2
#include "otlv4.h" // include the OTL 4.0 header file
otl_connect db; // connect object
int main()
{
otl_connect::otl_initialize(); // initialize OCI environment
try{
db.rlogon("XXX/XXX@DEV"); // connect to Oracle
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
//cerr<<p.stm_text<<endl; // print out SQL that caused the error
//cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Oracle
return 0;
}
在运行中出现:
error LNK2019: unresolved external symbol _OCIInitialize referenced in function "public: static int __cdecl otl_conn::initialize(int)" (?initialize@otl_conn@@SAHH@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIHandleFree referenced in function "public: int __thiscall otl_conn::server_detach(void)" (?server_detach@otl_conn@@QAEHXZ)
1>test.obj : error LNK2019: unresolved external symbol _OCIServerDetach referenced in function "public: int __thiscall otl_conn::server_detach(void)" (?server_detach@otl_conn@@QAEHXZ)
1>test.obj : error LNK2019: unresolved external symbol _OCISessionEnd referenced in function "public: int __thiscall otl_conn::session_end(void)" (?session_end@otl_conn@@QAEHXZ)
1>test.obj : error LNK2019: unresolved external symbol _OCIAttrSet referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIServerAttach referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIHandleAlloc referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIEnvInit referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCISessionBegin referenced in function "public: int __thiscall otl_conn::session_begin(char const *,char const *,int,int)" (?session_begin@otl_conn@@QAEHPBD0HH@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIErrorGet referenced in function "public: void __thiscall otl_conn::error(class otl_exc &)" (?error@otl_conn@@QAEXAAVotl_exc@@@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIDescriptorFree referenced in function "public: virtual __thiscall otl_var::~otl_var(void)" (??1otl_var@@UAE@XZ)
1>E:\C++project\jjj\Debug\jjj.exe : fatal error LNK1120: 11 unresolved externals
等一系列错误。
其中我的oracle客户端已经配置好为:
DEV =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = aaa.bbb.com)
(PORT = 1234)
)
)
(CONNECT_DATA =
(SERVICE_NAME = utf8dev)
)
)
并可以链接数据库。
想咨询下大神们,用这种方式使用OTL以OCI的方式链接数据库错在什么地方了???求指正
------解决方案--------------------
没有添加相应的库文件(*.lib)
程序如下,很简单
#include <iostream>
using namespace std;
#include <stdio.h>
#define OTL_ORA11G_R2
#include "otlv4.h" // include the OTL 4.0 header file
otl_connect db; // connect object
int main()
{
otl_connect::otl_initialize(); // initialize OCI environment
try{
db.rlogon("XXX/XXX@DEV"); // connect to Oracle
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
//cerr<<p.stm_text<<endl; // print out SQL that caused the error
//cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Oracle
return 0;
}
在运行中出现:
error LNK2019: unresolved external symbol _OCIInitialize referenced in function "public: static int __cdecl otl_conn::initialize(int)" (?initialize@otl_conn@@SAHH@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIHandleFree referenced in function "public: int __thiscall otl_conn::server_detach(void)" (?server_detach@otl_conn@@QAEHXZ)
1>test.obj : error LNK2019: unresolved external symbol _OCIServerDetach referenced in function "public: int __thiscall otl_conn::server_detach(void)" (?server_detach@otl_conn@@QAEHXZ)
1>test.obj : error LNK2019: unresolved external symbol _OCISessionEnd referenced in function "public: int __thiscall otl_conn::session_end(void)" (?session_end@otl_conn@@QAEHXZ)
1>test.obj : error LNK2019: unresolved external symbol _OCIAttrSet referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIServerAttach referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIHandleAlloc referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIEnvInit referenced in function "public: int __thiscall otl_conn::server_attach(char const *)" (?server_attach@otl_conn@@QAEHPBD@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCISessionBegin referenced in function "public: int __thiscall otl_conn::session_begin(char const *,char const *,int,int)" (?session_begin@otl_conn@@QAEHPBD0HH@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIErrorGet referenced in function "public: void __thiscall otl_conn::error(class otl_exc &)" (?error@otl_conn@@QAEXAAVotl_exc@@@Z)
1>test.obj : error LNK2019: unresolved external symbol _OCIDescriptorFree referenced in function "public: virtual __thiscall otl_var::~otl_var(void)" (??1otl_var@@UAE@XZ)
1>E:\C++project\jjj\Debug\jjj.exe : fatal error LNK1120: 11 unresolved externals
等一系列错误。
其中我的oracle客户端已经配置好为:
DEV =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = aaa.bbb.com)
(PORT = 1234)
)
)
(CONNECT_DATA =
(SERVICE_NAME = utf8dev)
)
)
并可以链接数据库。
想咨询下大神们,用这种方式使用OTL以OCI的方式链接数据库错在什么地方了???求指正
------解决方案--------------------
没有添加相应的库文件(*.lib)