VMware中安装Red Hat linux.as v4.0遇到的问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VMware中安装Red Hat linux.as v4.0遇到的问题相关的知识,希望对你有一定的参考价值。
参考技术A 可能是你建立新VMware时,你选的系统不是Linux..还有选择系统的时候你要选到linux下的redhat并且是符合你的系统盘的...要不然的话就不能装系统.还有硬盘一定要用IDE的,要不然你分区的时候就分不了!
Red Hat Enterprise Linux AS4, C++ OCCI connect Oracle 9i
前提是已经安装好Oracle 9i。
1. 下载对应的ORACLE client安装。
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
因为没有9i的client提供下载了,我选择最接近的版本下载:
Version 10.1.0.5
Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
Download instantclient-basic-linux32-10.1.0.5-20060511.zip (31,413,713 bytes) (cksum - 384697539)
下载之后解压。
2. 先把示例代码给出来:
//oci.cpp
#include <iostream> #include <string> #include <occi.h> using namespace std; using namespace oracle::occi; int main() { Connection *conn; Environment *env; Statement *stmt; //build a connection string struser("scott"); string strpwd("tiger"); string strconn_string(""); cout << "1" << endl; env = Environment::createEnvironment(Environment::OBJECT); cout << "2" << endl; conn = env->createConnection(struser, strpwd, strconn_string); cout << "3" << endl; if( NULL != conn) cout << "conn success" << endl; else cout << "conn failed" << endl; //execute sql statement string strsql("select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) from dual"); stmt = conn->createStatement(strsql); ResultSet *rset = stmt->executeQuery(); while(rset->next()) { string time = rset->getString(1); cout << "now time:" << time << endl; } //close resourses stmt->closeResultSet(rset); conn->terminateStatement(stmt); env->terminateConnection(conn); Environment::terminateEnvironment(env); return 0; }
3. 编译
这里对g++的版本有要求,如果是g++ 3.x.x的,可能会爆出如下错误:
undefined reference to `oracle::occi::Environment::createEnvironment(orac le::occi::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))‘
网上很多讨论这个错误的,解决办法是安装低版本的g++。
资料(可以不看):解决方案的出处:http://www.dbforums.com/showthread.php?1619980-Makefile-problem-for-OCCI-on-Oracle-9i
If you‘re getting the following error messages:
undefined reference to `oracle:occi::Environment::createEnvironment(oracle:occi::Environment::Mode, void*, void* (*)(void*, unsigned), void* (*)(void*, void*, unsigned), void (*)(void*, void*))‘
and
undefined reference to `oracle:occi::Environment::terminateEnvironment(oracle:occi::Environment*)‘
then you‘re probably running oracle9i on redhat 8.0. to solve this, download and install the following rpm‘s from this redhat link:
* compat-gcc-7.3-2.96.118.i386.rpm
* compat-gcc-c++-7.3-2.96.118.i386.rpm
* compat-libstdc++-7.3-2.96.118.i386.rpm
* compat-libstdc++-devel-7.3-2.96.118.i386.rpm
and compile with g++296 instead of g++. sure you‘ll be stuck with g++-2.96, but at least it will compile and run.
在谷歌搜索如下4个rpm包安装:
* compat-gcc-7.3-2.96.118.i386.rpm
* compat-libstdc++-7.3-2.96.118.i386.rpm
* compat-libstdc++-devel-7.3-2.96.118.i386.rpm
* compat-gcc-c++-7.3-2.96.118.i386.rpm
请按照安装上述顺序安装rpm包,因为最后一个依赖于第一二三个。
如果安装的时候报错说“正在安装的g++与系统上存在的g++有冲突”,在rpm后加上-aid --force参数,如下:
sudo rpm -ivh xxx.rpm -aid --force
详情可见这篇文:http://www.cnblogs.com/duanguyuan/p/4118210.html
安装好此版本的g++后,就可以用以下命令编译了:
g++296 -o oci -I /opt/oracle/product/rdbms/public/ -I /opt/oracle/product/rdbms/demo/ -I /home/oracle/instantclient10_1/ -L /opt/oracle/product/lib/ -L /opt/oracle/product/rdbms/lib/ oci.cpp -lclntsh -locci /usr/lib/libstdc++.so.5 -Wall -O -g
注意仔细看上边所包含的编译目录,先看看自己的$ORACLE_HOME在哪里,看看上述的目录都在不在。其中instantclient10_1目录便是第一步下载的Oracle client。
4. 运行
结果如下图
其他参考:
http://blog.csdn.net/gyanp/article/details/6107044
http://oradim.blogspot.com/2009/08/getting-started-with-occi-linux-version.html
以上是关于VMware中安装Red Hat linux.as v4.0遇到的问题的主要内容,如果未能解决你的问题,请参考以下文章
Linux(Red Hat)-中安装Vmware Tools
在VMware虚拟机中安装Linux系统(Red Hat Enterprise Linux7 64位系统)
windows系统安装虚拟机VMware12,然后在虚拟机中安装Red Hat Enterprise Linux6操作系统