Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to compile and execute a Pro*C program on Unix?

518258Nov 3 2009 — edited Nov 5 2009
Hello Gurus,

I am new to Pro*C. I just wrote a sample Pro*C program 'first.pc' to read some information from some tables and print it on screen.
I am not sure how to compile it and execute it to see the output of my very first program.

After searching a lot I tried following ..
-- Step 1 compile the program into .c program
 
$->ls -lrt first.pc
-rwxrwxrwx    1 sqloper4 staff          1069 Oct 31 03:39 first.pc
$->proc first.pc
 
Pro*C/C++: Release 8.1.7.0.0 - Production on Sat Oct 31 05:43:35 2009
 
(c) Copyright 2000 Oracle Corporation.  All rights reserved.
 
System default option values taken from: /oracle/app/oracle/product/8.1.7/precomp/admin/pcscfg.cfg
 
$->ls -lrt first*
-rwxrwxrwx    1 sqloper4 staff          1069 Oct 31 03:39 first.pc
-rw-r--r--    1 sqloper4 staff             0 Oct 31 05:43 first.lis
-rw-r--r--    1 sqloper4 staff          6648 Oct 31 05:43 first.c
 
$->
 
-- Step 2 Generate the .o file
 
$->cc -I${ORACLE_HOME}/precomp/public -c first.c
first.c: In function 'main':
first.c:154: warning: return type of 'main' is not 'int'
 
$->
 
$->ls -lrt first*
-rwxrwxrwx    1 sqloper4 staff          1069 Oct 31 03:39 first.pc
-rw-r--r--    1 sqloper4 staff             0 Oct 31 05:43 first.lis
-rw-r--r--    1 sqloper4 staff          6648 Oct 31 05:43 first.c
-rw-r--r--    1 sqloper4 staff          3709 Oct 31 05:45 first.o
 
$->
 
-- Step 3 After that link the .o to libraries and produce the exe
 
$->cc -o exe_name -L $ORACLE_HOME/lib -lclntsh
ld: 0711-317 ERROR: Undefined symbol: .main
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status
 
$->
 
$->ls -lrt first*
-rwxrwxrwx    1 sqloper4 staff          1069 Oct 31 03:39 first.pc
-rw-r--r--    1 sqloper4 staff             0 Oct 31 05:43 first.lis
-rw-r--r--    1 sqloper4 staff          6648 Oct 31 05:43 first.c
-rw-r--r--    1 sqloper4 staff          3709 Oct 31 05:45 first.o
$->
I also tried below steps after some time with new program
$->ls -lrt first*
-rwxrwxrwx    1 sqloper4 staff          1069 Oct 31 03:39 first.pc
$->
$->proc first.pc

Pro*C/C++: Release 8.1.7.0.0 - Production on Tue Nov 3 05:42:14 2009

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

System default option values taken from: /oracle/app/oracle/product/8.1.7/precomp/admin/pcscfg.cfg

$->cc first.c
first.c:142:19: error: sqlca.h: A file or directory in the path name does not exist.
first.c: In function 'main':
first.c:170: error: 'sqlca' undeclared (first use in this function)
first.c:170: error: (Each undeclared identifier is reported only once
first.c:170: error: for each function it appears in.)
first.c:154: warning: return type of 'main' is not 'int'
first.c: In function 'sqlerror':
first.c:260: error: 'sqlca' undeclared (first use in this function)
$->
Can anybody help me on above errors?

After all above still I am not sure how to proceed and 'execute' the program.
Could you please help me with the steps to 'Compile and execute' a Pro*C program ?

Oracle DB Version : Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
OS : Unix


Thanks in advance!

Edited by: Learning.Oracle on Nov 3, 2009 5:13 PM
This post has been answered by Mark Williams-Oracle on Nov 5 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2009
Added on Nov 3 2009
4 comments
3,956 views