[英]Connecting c++ program with Oracle using occi library
I'm trying to connect my C++ program to Oracle database(12.1).我正在尝试将我的 C++ 程序连接到 Oracle 数据库(12.1)。
My C++ program at the moment is (I am using mingw64 g++ compiler in windows):我目前的 C++ 程序是(我在 Windows 中使用 mingw64 g++ 编译器):
#include <occi.h>
void oracle_connect()
{
using namespace oracle::occi;
using namespace std;
Environment *env;
Connection *conn;
Statement *stmt;
env = Environment::createEnvironment (Environment::DEFAULT);
conn = env->createConnection ("dasdas", "dasdas", "dasdas");
}
int main()
{
oracle_connect();
}
I compile my program using this command:我使用以下命令编译我的程序:
g++ test.cpp -loci -lociw32 -loraocci12
All those libraries (oraocci12.lib ociw32.lib oci.lib) are from my oracle folder: oracle\\product\\12.1.0\\client_1\\oci\\lib\\msvc所有这些库(oraocci12.lib ociw32.lib oci.lib)都来自我的 oracle 文件夹:oracle\\product\\12.1.0\\client_1\\oci\\lib\\msvc
But I got error during compilation:但是在编译过程中出现错误:
undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))'
How should I properly link over my program to successfuly compile it?我应该如何正确链接我的程序以成功编译它?
In the project I am working the config is the following在我正在工作的项目中,配置如下
#----- Environnement specifique Oracle -----
ORACLEINC = $(ORACLE_HOME_DEV)/include
ORACLELIB = $(ORACLE_HOME_DEV)/lib32
ORACLEBIN = $(ORACLE_HOME_DEV)/bin
ORAINC = -I$(ORACLEINC) -I$(ORACLE_HOME_DEV)/rdbms/demo -I$(ORACLE_HOME_DEV)/precomp/public -I$(ORACLE_HOME_DEV)/plsql/public -I$(ORACLE_HOME_DEV)/network/public
ORALIB = -L$(ORACLELIB) -L$(ORACLE_HOME_DEV)/rdbms/lib -L$(ORACLE_HOME_DEV)/precomp/lib -L$(ORACLE_HOME_DEV)/plsql/lib -L$(ORACLE_HOME_DEV)/network/lib
where ORACLE_HOME_DEV --> /exec/products/oracle/v10.2/
其中
ORACLE_HOME_DEV --> /exec/products/oracle/v10.2/
The library you are looking for shoule be here你要找的图书馆在这里
libocci.a.10.1 -> /exec/products/oracle/v10.2/lib32/libocci.a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.