2

我使用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)
4

1 回答 1

0

出于某种原因,编译器弄乱了 oracle 标头中回调的调用约定。尝试:

#pragma managed(push, off)
#include <occi.h>
#include <oratypes.h>
#pragma managed(pop)
于 2011-03-10T01:31:28.507 回答