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::Environm开发者_如何学运维ent::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)
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)
精彩评论