从 vc++ 链接到 oci 库时出错

发布于 2024-10-21 05:01:40 字数 2246 浏览 2 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青丝拂面 2024-10-28 05:01:40

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

#pragma managed(push, off)
#include <occi.h>
#include <oratypes.h>
#pragma managed(pop)

For some reason, the compiler is messing with the calling convention of callbacks in the oracle headers. Try:

#pragma managed(push, off)
#include <occi.h>
#include <oratypes.h>
#pragma managed(pop)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文