Compile and link Pro*C simple program

I'm new to Pro*C. I had made a simple program (test.pc) to begin
programming with Pro*C. My program is as follows:

#include <stdio.h>
#include <stdlib.h>
#include "/oracle/oracle/app/oracle/product/8.1.7/precomp/public/sqlca.h"

void main()
{
        char * uid = "/";
        int a;

    EXEC SQL CONNECT :uid;

    EXEC SQL SELECT count(id) INTO :a
             FROM tab
             WHERE status=4;
    printf("The number of rows is: %d\n", a);
    exit(0);
}

I compiled from Pro*C to C without any problem using the following command:
$ proc test.pc

Now, I need to compile from C:
I copied demo_proc.mk from $ORACLE_HOME/precomp/demo/proc and just change the line with environment variable SAMPLES to put my program name: test. It looks like:

SAMPLE=test

After I execute the make command as follows:
make -f demo_proc.mk

I just got this line with no output:
`/oracle/oracle/app/oracle/product/8.1.7/lib/libclntsh.sl' is up to date.

Could anyone help me to compile my first file?

My environment:
Machine: HP-UX B.11.11 U 9000/800
Pro*C/C++: Release 8.1.7.0.0
C compiler provided by HP-UX: cc

Thanks in Advance
LVL 1
ikhnaton2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RCorfmanCommented:
The line that you got is saying that it didn't hink it needed to compile the library. I think the .mk file needs input on top of what was provided... but I don't know for sure because the development environment I used generated the .mk files on the fly and ran them.

I haven't used pro*c on hp-ux, I have on Windows.  I don't know if these will help or not (I don't usually spam links, but in this case...).
http://www.experts-exchange.com/Programming/Q_21121227.html

This makes reference to using this line with that .mk file..
I use this command to compile:
/usr/bin/make -f /apps/oracle/ora817/precomp/demo/proc/demo_proc.mk build EXE=pgsqlldr OBJS=pgsqlldr.o CODE=ansi_c MODE=ansi
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RCorfmanCommented:
Here are a couple of other links that may help (again, I'm sorry I don't have more direct input):
http://www.experts-exchange.com/Databases/Oracle/Q_10716941.html
Here is one that isn't hp-ux specific, it is unix though, and seems to show more instruction on how to compile the demo...
http://www.experts-exchange.com/Databases/Oracle/Q_20318763.html
And I think this one looks like it may have lot's of clear instruction on compiling a program. Also discusses pro*c vs. OCI arguments.
http://www.experts-exchange.com/Databases/Oracle/Q_21067492.html

This one seems more remote, but also has some refernce info
http://www.experts-exchange.com/Databases/Oracle/Q_20150898.html
0
ikhnaton2Author Commented:
Thanks RCorfman for the answer.
I'm reading the references provided by you, I think I got close to find the answer:

I tried this command
make -f demo_proc.mk build EXE=test OBJS=test.o CODE=ansi_c MODE=ansi

Output was:
cc   -o test  test.o -L/oracle/oracle/app/oracle/product/8.1.7/lib/ -lclntsh   `cat /oracle/oracle/app/oracle/product/8.1.7/lib/sysliblist`  -lm  -lpthread -lpthread

Then I got, at last, the executable file: test

When I tried to execute:
$ test

No output at all.

I changed the code to contain Error Handling like this:
#include <stdio.h>
#include <stdlib.h>
#include "/oracle/oracle/app/oracle/product/8.1.7/precomp/public/sqlca.h"

/* Error handling function. */
void sql_error(void)
{
    EXEC SQL WHENEVER SQLERROR continue;
    printf("%.70s\n", sqlca.sqlerrm.sqlerrmc);
    exit(1);
}

void main()
{
    char * uid = "/";
    int a;

    EXEC SQL WHENEVER SQLERROR do sql_error();
    EXEC SQL CONNECT :uid;

    EXEC SQL SELECT count(id) INTO :a
             FROM tab
             WHERE status=4;
    printf("The number of rows is: %d\n", a);
    exit(0);
}

Compile from Proc*C to C successfully. Then compile from C using the above make command, the output is:
cc      -I. -I/oracle/oracle/app/oracle/product/8.1.7/precomp/public -I/oracle/oracle/app/oracle/product/8.1.7/rdbms/public -I/oracle/oracle/app/oracle/product/8.1.7/rdbms/demo -I/oracle/oracle/app/oracle/product/8.1.7/plsql/public -I/oracle/oracle/app/oracle/product/8.1.7/network/public       -c test.c

cc   -o test  test.o -L/oracle/oracle/app/oracle/product/8.1.7/lib/ -lclntsh   `cat /oracle/oracle/app/oracle/product/8.1.7/lib/sysliblist`  -lm  -lpthread -lpthread

Again trying to execute:
$ test

No output at all without even an error message.

What's wrong?
0
RCorfmanCommented:
I would put a printf at the very start of main to ensure it is even running... I agree it seems that you should get some output.
0
ikhnaton2Author Commented:
Actually the files seems to be built successfully but as I name it "test". When I try to execute it as:
$ test
It run a shell command called "test" which is condition evaluation command.

I should, instead, run the command as follows:
$ ./test
and it works as I wanted.

It was a silly problem, my fault. Your answer has been accepted. Thanks for your help.

P.S.
I would like to mention here that this link: http://www.experts-exchange.com/Databases/Oracle/Q_21067492.html ,
provide by you in the 2nd comment, contains valuable information.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.