Oracle数据库开发(三) Pro*C/C++的编译参数

news/2024/6/18 6:00:21 标签: oracle, 数据库, makefile, include, warnings, build
Oracle Database Development (4). Example Makefile for Pro*C
 
<本文主要介绍Linux下使用Makefile编译ProC程序的方法>
It is a pity that there is a few aritcle written in Chinese which talking about
the material method of Makefile for Pro*C/C++ .Maybe it's not diffcult to the most
Linux developers , but I find lots of questions about the method of compile
which follows no answer .
I don't know why .
1.Preface
 Assumed that you just finished the installation of Oracle Pro*C In Linux OS ,
 you hurry to enter the directory which contains lots of Pro*C examples and type
 this command " make -f demo_proc.mk sample1 " to get a first programme. In all
 probability you could find lots of errors and warnings full of the screen instead
 of a imaged executable file.
 
 Don't worry , let us discover the secrect in it , which is the mainly content
 of this artical.
 Oracle DataBase Development Series
  http://blog.csdn.net/liwei_cmg/category/207442.aspx

2.The causation of errors
 In the beginning , I was also puzzled with this errors , for i had no idea with
 Precompiler Options . Everything becomes clear go with the knowing the Precompiler
 Options.
 
 Input your command " proc parse=? " at the command line .
  $ proc parse=?
 
 You should see the prompt following .
 
  Pro*C/C++: Release 9.2.0.4.0 - Production on Fri Jun 8 12:22:36 2007
  
  Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
  
  System default option values taken from: /home/ora/ora9/oracle/precomp/admin/pcscfg.cfg
  
  Option name   :  parse=string
  Current value :  full
  Restrictions  :  full, partial, none
  Description   :  Control which non-SQL code is parsed
  PCC-F-02135, CMD-LINE:  User asked for help
  Check the makefile named "demo_proc.mk" and the predefined environment file
 named "env_precomp.mk" , and you will find the variable $(PROCFLAGS) not defined .
 Oralce used the default value when compiled the sample. According to last article
 《Oracle Database Development (3). Introduce to Pro*C/C++ Precompiler Options》,
 we know that we should set the value of SYS_INCLUDE option. Just follow the
 instruction , you would get a better result .
 
 The key step of the compilers listed on the sceen is perhaps like this :
 
 proc  iname=sample1 include=. include=/home/ora/ora9/oracle/precomp/public include=/home/ora/ora9/oracle/rdbms/public include=/home/ora/ora9/oracle/rdbms/demo include=/home/ora/ora9/oracle/plsql/public include=/home/ora/ora9/oracle/network/public
 /usr/bin/gcc  -O3  -trigraphs -fPIC -DPRECOMP -I. -I/home/ora/ora9/oracle/precomp/public -I/home/ora/ora9/oracle/rdbms/public -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/plsql/public -I/home/ora/ora9/oracle/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: warning: return type of `main' is not `int'
 
 /usr/bin/gcc -o sample1 sample1.o -L/home/ora/ora9/oracle/lib/ -lclntsh `cat /home/ora/ora9/oracle/lib/ldflags`   `cat /home/ora/ora9/oracle/lib/sysliblist` -ldl -lm 
 sample1.o(.text+0x3b6): In function `main':
 : the `gets' function is dangerous and should not be used.
 
 Some warnings comes again , i don't mind , for we have already known what it is !
 
3.Using Oracle defined Makefile
  Here is the detail below.
 
  Copy the file "demo_proc.mk" to your own directory and rename it by yourself .
  The source file " main.pc " , which have the same content with the example mentioned
  before , is created then .
 
   [ora@liwei src]$ ls
   main.pc   proc.mk
 
  Add the "-lclntsh" to the file "$ORACLE_HOME/lib/sysliblist" .
 
   [ora@liwei lib]$ cat sysliblist
   -lclntsh -ldl -lm -lpthread -lnsl -lirc
 
  Start to compile .
 
   [ora@liwei src]$ make -f proc.mk main
  
  make -f /home/ora/ora9/oracle/precomp/demo/proc/demo_proc.mk PROCFLAGS="" PCCSRC=main I_SYM=include= pc1
  make[1]: Entering directory `/home/ora/develop/src'
  proc  iname=main include=. include=/home/ora/ora9/oracle/precomp/public include=/home/ora/ora9/oracle/rdbms/public include=/home/ora/ora9/oracle/rdbms/demo include=/home/ora/ora9/oracle/plsql/public include=/home/ora/ora9/oracle/network/public
  
  Pro*C/C++: Release 9.2.0.4.0 - Production on Fri Jun 8 16:18:20 2007
  
  Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
  
  System default option values taken from: /home/ora/ora9/oracle/precomp/admin/pcscfg.cfg
  
  make[1]: Leaving directory `/home/ora/develop/src'
  /usr/bin/gcc  -O3  -trigraphs -fPIC -DPRECOMP -I. -I/home/ora/ora9/oracle/precomp/public -I/home/ora/ora9/oracle/rdbms/public -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/plsql/public -I/home/ora/ora9/oracle/network/public -DLINUX -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -DSLTS_ENABLE -DSLMXMX_ENABLE -D_REENTRANT -DNS_THREADS    -c main.c
  /usr/bin/gcc -o main -L/home/ora/ora9/oracle/precomp/lib/ -L/home/ora/ora9/oracle/lib/ -L/home/ora/ora9/oracle/lib/stubs/  main.o    `cat /home/ora/ora9/oracle/lib/sysliblist` -ldl -lm  -o main
  rm main.o 
 
  Everything is OK now.
 
4.Make your own Makefile

  The Makefile defined by Oracle can compile any Pro*C/C++ file . Someone may
  prefer to make a new one by themselves, which is more simple .
  Due to the existence of the powerfull Oracle Makefile , it becomes a piece of cake .
 
  Let me list the content of a simple file .
 
  [ora@liwei src]$
  [ora@liwei src]$ pwd
  /home/ora/develop/src
  [ora@liwei src]$ ls
  Makefile  main.pc   proc.mk
  [ora@liwei src]$ cat Makefile
  include $(ORACLE_HOME)/precomp/lib/env_precomp.mk
  
  # PROC, CFLAGS, LDPATHFLAG, LIBHOME, PROLDLIBS are defined in env_precomp.mk
  # Redhat Linux
  CC=/usr/bin/gcc
  
  build: $(OBJS)
          $(DEMO_PROC_BUILD_SHARED)
  main:
          $(MAKE) -f Makefile OBJS=$@.o EXE=$@ build
  clean:
          rm main *.o *.lis *.c
  
  .SUFFIXES: .pc .c .o
      
  .pc.c:
          $(PROC) $(PROCFLAGS) iname=$*
  
  .pc.o:
          $(PROC) $(PROCFLAGS) iname=$*
          $(C2O)
  .c.o:
          $(C2O)
 
 The statement "$(MAKE) -f Makefile OBJS=$@.o EXE=$@ build" could be considerd
 a entrance of the complier . $@ actually means "main" in this sentence.
 The target 'build' puts together an executable $(EXE) from the .o files in
 $(OBJS) and the libraries in $(PROLDLIBS). You can get the following message
 if your find it in "env_precomp.mk"
 
 DEMO_PROC_BUILD_SHARED_32=$(CC) $(LFLAGS32) -o $(EXE) $(OBJS) $(LDPATHFLAG)$(LIBHOME) $(PROLDLIBS)
 Search the key word "Makefile" in Google for more details about it.
 
  $ make clean
  $ make main
  
 Note: "make main" equals "make -f Makefile main".
 
  
5.Postscript
  Makefiles are special format files that together with the make utility will help
  you to automagically build and manage your projects.
 
  Most of the Windows developers strange with the theory of Makefile ,for Windows
  IDE have nearly done every work at the aspect of compile . The Makefile is known
  as nmake in VC IDE . Every developer , i think , should know the theory more or
  less . 

http://www.niftyadmin.cn/n/1089648.html

相关文章

手机能给电脑装系统吗_新电脑怎么装系统

大家好&#xff0c;我是小白一键重装软件的客服。新电脑怎么装系统呢&#xff1f;很多小伙伴喜欢自己购买电脑主机配件DIY组装电脑&#xff0c;那么主机配置好后硬盘没有操作系统&#xff0c;也是没办法使用电脑&#xff0c;如何给新电脑安装系统呢&#xff1f;下面小白系统教你…

kali 2.0 安装VMware Tools

虽然这不是一个多么困难的&#xff0c;或者有技术含量的文章&#xff0c;但是看到身边确实有不少新手朋友会遇到这个问题来求助&#xff0c;我百度了一下&#xff0c;要么讲的太复杂&#xff0c;要么实施起来存在问题&#xff0c;清晰、简单的文章确实没看到&#xff0c;所以写…

arraylist排序_面试必会排序算法(1)java 实现冒泡排序讲解

创作目的最近想系统整理一下数据库的索引系列&#xff0c;然后就牵扯到了二分查找&#xff0c;二分查找的前提需要排序。排序工作中我们用的很多&#xff0c;不过很少去关心实现&#xff1b;面试中&#xff0c;排序的出场率非常高&#xff0c;以此来验证大家是否懂得“算法”。…

面试笔记3

&#xff08;1&#xff09;快排是递归排序&#xff0c;为啥排序效率也挺高&#xff1f;快排是通过一趟排序将要排序的数据分割成独立的两部分&#xff0c;其中一部分的所有数据都比另外一部分的所有数据都要小&#xff0c;然后再按此方法对这两部分数据分别进行快速排序&#x…

oracle数据库开发的一些经验积累(一)

1、不安装Oracle客户连接Oracle 8的方法 请将以下文件拷贝到运行文件所在目录 一、ODBC动态库 : ctl3d32.dll msvcrt40.dll odbc16gt.dll odbc32.dll odbc32gt.dll odbccp32.dll odbccr32.dll odbcint.dll 二、建立EXTRA子目录&#xff0c;将MSVCRT.DLL文件拷贝到该子目录…

接口测试用例设计实践总结

设计思路 1) 优先级--针对所有接口 1、暴露在外面的接口&#xff0c;因为通常该接口会给第三方调用&#xff1b; 2、供系统内部调用的核心功能接口&#xff1b; 3、供系统内部调用非核心功能接口&#xff1b; 2) 优先级--针对单个接口 1、正向用例优先测试,逆向用例次之(通…

苹果4s怎么越狱教程_教你苹果手机(iPhone)上怎么装KODI (不用越狱)

教你怎么在苹果手机&#xff08;iPhone&#xff09;上装KODI &#xff08;不用越狱&#xff09;不管你是喜欢在网上追剧的还是喜欢看4k电影的&#xff0c;当提到KODI&#xff08;XBMC&#xff09;估计没有人不认识&#xff0c;KODI前身叫XBMC&#xff0c;因为强大的解码能力和出…

oracle数据库开发的一些经验积累(二)

16、TNS:没有监听器的问题。 (1)查一下监听服务是否启动&#xff0c; 如果没有启动&#xff0c;则运行lsnrctrl start。(2)查看一下 LISTENER.ORA内监听的服务器名、服务器IP、数据库名是否正确。(3)查看一下 TNSNAMES.ORA内服务器名、服务器IP、数据库名是否正确。 17、LI…