我使用oracle 9i(个人edtn)的OCI库从我的c程序连接到数据库。(即时通讯使用visual c ++ 2005) 我已经包含了来自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)
答案 0 :(得分:0)
由于某种原因,编译器正在搞乱oracle头中回调的调用约定。尝试:
#pragma managed(push, off)
#include <occi.h>
#include <oratypes.h>
#pragma managed(pop)