我使用OCI库从oracle 9i(personal edtn)从我的c程序连接到数据库(使用visual c + + 2005) 我包括所有lib文件从oci并包括它们在额外的依赖也,但当我编译下面的代码我得到链接器错误 。错误链接到oci库从vC++
#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 *))" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@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 *))" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
请注意,这不是一个C程序,它是一个C++/CLI程序。 – 2011-03-09 15:45:46