从 vc++ 链接到 oci 库时出错
我使用 Oracle 9i(个人 edtn)中的 OCI 库从我的 C 程序连接到数据库。(我使用 Visual C++ 2005) ive 包含了 oci 中的所有 lib 文件,并将它们也包含在附加依赖项中,但是 当我编译以下代码时,出现链接器错误。
#include "stdafx.h"
#include "Form1.h"
#include <occi.h>
#include<oratypes.h>
using namespace ovci;
using namespace oracle;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
oracle::occi::Environment* environment;
oracle::occi::Connection *con;
oracle::occi::Statement* stmt;
oracle::occi::ResultSet* res;
environment = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
con = environment->createConnection("scott", "tiger", "");
stmt = con->createStatement("select * from emp2");
res = stmt->executeQuery();
stmt->closeResultSet(res);
con->terminateStatement(stmt);
environment->terminateConnection(con);
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
return 0;
}
我得到的错误是,
ovci.obj : error LNK2028: unresolved token (0A000016) "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
ovci.obj : error LNK2019: unresolved external symbol "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
Im using the OCI libraries from oracle 9i(personal edtn) for connecting to the database from my c program.(im using visual c++ 2005)
ive included all lib files from oci and included them in the additional dependency also, but
when i compile the following code i get linker errors.
#include "stdafx.h"
#include "Form1.h"
#include <occi.h>
#include<oratypes.h>
using namespace ovci;
using namespace oracle;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
oracle::occi::Environment* environment;
oracle::occi::Connection *con;
oracle::occi::Statement* stmt;
oracle::occi::ResultSet* res;
environment = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
con = environment->createConnection("scott", "tiger", "");
stmt = con->createStatement("select * from emp2");
res = stmt->executeQuery();
stmt->closeResultSet(res);
con->terminateStatement(stmt);
environment->terminateConnection(con);
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
return 0;
}
the errors i get are,
ovci.obj : error LNK2028: unresolved token (0A000016) "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
ovci.obj : error LNK2019: unresolved external symbol "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于某种原因,编译器弄乱了 oracle 标头中回调的调用约定。尝试:
For some reason, the compiler is messing with the calling convention of callbacks in the oracle headers. Try: