1. 예제 파일 다운로드하기
1) 오라클을 인스톨해도 예제가 들어있지 않기에 밑의 사이트로부터 다운로드 하자.
http://www.oracle.com/technology/products/database/oracle11g/index.html
오른쪽의 download Oracle dababase 11g 를 클릭.
-> accept를 클릭하고
-> Linux x86 옆의 See All을 클릭한다.
-> accept를 클릭하고
-> Oracle Database 11g Examples (formerly Companion) 를 클릭하면 다운로드가 시작된다.
2) 인스톨
압축을 푼다.
unzip linux_11gR1_examples.zip
압축을 풀면, examples 디렉토리가 생기니 그리로 이동한다.
./runInstaller 를 실행한다.
그 다음은 [linux_11gR1_examples 인스톨하기]를 참조.
3) 컴파일
/opt/app/oracle/product/11.1.0/db_1/precomp/demo/proc 로 이동한다.
그리고 나서 다음의 명령어를 수행한다.$ make -f demo_proc.mk OBJS=sample1.o EXE=sample1 build
--------------- msg ------------------
make -f /opt/app/oracle/product/11.1.0/db_1/precomp/demo/proc/demo_proc.mk PROCFLAGS="" PCCSRC=sample1
I_SYM=include= pc1
make[1]: ディレクトリ `/opt/app/oracle/product/11.1.0/db_1/precomp/demo/proc' に入ります
proc iname=sample1
include=.
include=/opt/app/oracle/product/11.1.0/db_1/precomp/public
include=/opt/app/oracle/product/11.1.0/db_1/rdbms/public
include=/opt/app/oracle/product/11.1.0/db_1/rdbms/demo
include=/opt/app/oracle/product/11.1.0/db_1/plsql/public
include=/opt/app/oracle/product/11.1.0/db_1/network/public
Pro*C/C++: Release 11.1.0.6.0 - Production on 水 7月 2 23:38:53 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
システムのデフォルト・オプション値: /opt/app/oracle/product/11.1.0/db_1/precomp/admin/pcscfg.cfg
make[1]: ディレクトリ `/opt/app/oracle/product/11.1.0/db_1/precomp/demo/proc' から出ます
/usr/bin/gcc -O2 -fPIC -DPRECOMP -I. -I/opt/app/oracle/product/11.1.0/db_1/precomp/public
-I/opt/app/oracle/product/11.1.0/db_1/rdbms/public -I/opt/app/oracle/product/11.1.0/db_1/rdbms/demo
-I/opt/app/oracle/product/11.1.0/db_1/plsql/public -I/opt/app/oracle/product/11.1.0/db_1/network/public -DLINUX
-D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -DSLTS_ENABLE -DSLMXMX_ENABLE
-D_REENTRANT -DNS_THREADS -c sample1.c
sample1.c: In function ‘main’:
sample1.c:241: 警告: return type of ‘main’ is not ‘int’
/usr/bin/gcc -o sample1 sample1.o -L/opt/app/oracle/product/11.1.0/db_1/lib/ -lclntsh `cat
/opt/app/oracle/product/11.1.0/db_1/lib/ldflags` `cat /opt/app/oracle/product/11.1.0/db_1/lib/sysliblist` -lm
sample1.o: In function `main':
sample1.c:(.text+0x434): warning: the `gets' function is dangerous and should not be used.
4) 실행하기
$ ./sample1
Connected to ORACLE as user: scott
Enter employee number (0 to quit): 7521
Employee Salary Commission
-------- ------- ----------
WARD 1250.00 500.00
Enter employee number (0 to quit): 1234
Not a valid employee number - try again.
Enter employee number (0 to quit): 0
Total rows returned was 1.
G'day.
[출처] Oracle pro*C/C++ 예제실행하기|작성자 제이슨