2

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)
James McNellis
  • 348,265
  • 75
  • 913
  • 977
Ajanth
  • 2,435
  • 3
  • 20
  • 23

1 Answers1

0

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)
Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • thanks The error was i tried to use pragma in clr/pure mode. now ive changewd it to clr normal mode and ur code is working well. thanks. And woulkd changing from clr pure to clr normal mode affect my forms in any way. coz I dont know what is clr pure mode and normal mode. – Ajanth Mar 12 '11 at 09:13
  • In `/clr` mode, you get a mixed-mode assembly which has part MSIL and part native code. The MSIL code is CPU-independent, but the native code is either 32-bit or 64-bit, you need a different DLL for each. Because you are using a native library for Oracle, I don't see any way around using mixed-mode. In `/clr:pure`, the result is only MSIL and you can run in 32-bit or 64-bit mode using the same DLL. In `/clr:safe` mode, the result is only verifiable MSIL which allows you to run inside a partial trust sandbox. – Ben Voigt Mar 12 '11 at 15:02