Home » Developer & Programmer » Precompilers, OCI & OCCI » C+ and Oracle
C+ and Oracle [message #94338] Tue, 10 August 2004 03:08
Messages: 19
Registered: October 2001
Junior Member
I am trying to use the following code base to just connect with oracle. Looks like I am missing steps in the precompilation/inclusion of libraries in Makefile.

Platform - Solaris 8
Oracle 9i

include $(ORACLE_HOME)/rdbms/lib/env_rdbms.mk

#LIBS=-lclntsh -locci

two: two.cpp

rm -f two *.o *.out

# end of Makefile

Actual Code
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "./sqlda.h"
#include "./sqlcpr.h"
/* host variable*/

EXEC SQL begin declare section;

char user[[20]];

char pass[[20]];

EXEC SQL end declare section;

#include "./sqlca.h"

int main()




EXEC SQL connect :user identified by :pass;

printf ("byen");

return 0;


bash-2.03$ make two
gcc -o two -I. two.cpp -lclntsh `cat /opt/oracle/u01/app/oracle/product/9.2.0/lib/ldflags` `cat /opt/oracle/u01/app/oracle/product/9.2.0/lib/sysliblist` -
R/opt/oracle/u01/app/oracle/product/9.2.0/lib -laio -lposix4 -lkstat -lm -lthread
two.cpp:8: error: `EXEC' does not name a type
two.cpp:14: error: `EXEC' does not name a type
two.cpp: In function `int main()':
two.cpp:32: error: `EXEC' undeclared (first use this function)
two.cpp:32: error: (Each undeclared identifier is reported only once for each function it appears in.)
two.cpp:32: error: expected `;' before "SQL"
*** Error code 1
make: Fatal error: Command failed for target `two'

Previous Topic: ORA-00000 in Precompiler
Next Topic: SQLCode = -904
Goto Forum:

Current Time: Mon Sep 27 02:19:13 CDT 2021