Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Compiling for Oracle 8 - Illegal instruction(coredump)
Questing is, what is wrong - compilation process (options), gcc compiler or
Oracle libraries?
I'm using gcc version 2.95, ld from binutils 2.9. I compiled the following file using commands:
/app/oracle/product/8.0.5/bin/proc code=cpp parse=none sqlcheck=full
userid=vodev/vodev_at_dbprex
sys_include='(/app/opensgc/preisch/include/g++-3,/usr/lib/gcc-lib/powerpc-ib
m-aix4.2.1.0/2.95/include,/usr/include)' iname=sample1
g++ -c -I. -I/app/oracle/product/8.0.5/precomp/public -I/app/oracle/product/ 8.0.5/rdbms/public -I/app/oracle/product/8.0.5/rdbms/demo -I/app/oracle/prod uct/8.0.5/plsql/public -I/app/oracle/product/8.0.5/network/public sample1.c
ld -Ur sample1.o -o libsample1.a
g++ -L. -lsample1 -L/app/oracle/product/8.0.5/lib/ -lclntsh
/app/oracle/product/8.0.5/lib/scorept.o /app/oracle/product/8.0.5/lib/sscoreed.o /app/oracle/product/8.0.5/rdbms/lib/kpudfo.o -lclient -lsql /app/oracle/product/8.0.5/lib/nautab.o /app/oracle/product/8.0.5/lib/naeet.o /app/oracle/product/8.0.5/lib/naect.o /app/oracle/product/8.0.5/lib/naedhs.o`cat
/app/oracle/product/8.0.5/lib/libplsf.a /app/oracle/product/8.0.5/lib/libplsb.a /app/oracle/product/8.0.5/lib/libextp.a -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsr tl3 -lcore4 -lnlsrtl3 `cat
I compiles OK. But when executing sample1, it gives the following output:
Before connect.
Illegal instruction(coredump)
sample1.pc reads:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqlda.h>
#include <sqlcpr.h>
EXEC SQL INCLUDE sqlca;
EXEC SQL BEGIN DECLARE SECTION;
#define UNAME_LEN 20
#define PWD_LEN 40
char username[UNAME_LEN]; char password[PWD_LEN]; char tns[20];
char err_msg[128];
size_t buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\n%s\n", msg);
buf_len = sizeof (err_msg);
sqlglm(err_msg, &buf_len, &msg_len);
printf("%.*s\n", msg_len, err_msg);
EXEC SQL ROLLBACK RELEASE;
exit(EXIT_FAILURE);
}
void main()
{
char temp_char[32];
strcpy((char *) username, "vodev"); strcpy((char *) password, "vodev"); strcpy((char *) tns, "tns:dbprex");
printf("Before connect.\n");
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :tns;
printf("\nConnected to ORACLE as user: %s\n", username);
printf("\nG'day.\n\n\n");
/* Disconnect from ORACLE. */
EXEC SQL ROLLBACK WORK RELEASE; printf("\nDisconnected.\n");
exit(EXIT_SUCCESS);
}
precompiled sample1.c reads:
/* Result Sets Interface */
#ifndef SQL_CRSR
# define SQL_CRSR
struct sql_cursor
{
unsigned int curocn;
void *ptr1;
void *ptr2;
unsigned long magic;
};
typedef struct sql_cursor sql_cursor;
typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */
/* Thread Safety */
typedef void * sql_context;
typedef void * SQL_CONTEXT;
/* Object support */
struct sqltvn
{
unsigned char *tvnvsn;
unsigned short tvnvsnl;
unsigned char *tvnnm;
unsigned short tvnnml;
unsigned char *tvnsnm;
unsigned short tvnsnml;
};
typedef struct sqltvn sqltvn;
struct sqladts
{
unsigned int adtvsn;
unsigned short adtmode;
unsigned short adtnum;
sqltvn adttvn[1];
};
typedef struct sqladts sqladts;
static struct sqladts sqladt = {
1,1,0,
};
/* Binding to PL/SQL Records */
struct sqltdss
{
unsigned int tdsvsn;
unsigned short tdsnum;
unsigned char *tdsval[1];
};
typedef struct sqltdss sqltdss;
static struct sqltdss sqltds =
{
1,
0,
};
/* File name & Package Name */
struct sqlcxp
{
unsigned short fillen;
char filnam[11];
};
static const struct sqlcxp sqlfpn =
{
10,
"sample1.pc"
};
static unsigned long sqlctx = 78451;
static struct sqlexd {
unsigned int sqlvsn;
unsigned int arrsiz;
unsigned int iters;
unsigned int offset; unsigned short selerr; unsigned short sqlety; unsigned int unused; const short *cud; unsigned char *sqlest; const char *stmt;
void **sqphsv; unsigned int *sqphsl; int *sqphss; void **sqpind; int *sqpins; unsigned int *sqparm; unsigned int **sqparc;
void *sqhstv[4];
unsigned int sqhstl[4];
int sqhsts[4]; void *sqindv[4]; int sqinds[4];
unsigned int *sqharc[4]; unsigned short sqadto[4]; unsigned short sqtdso[4];
// Prototypes
extern "C" {
void sqlcxt (void **, unsigned long *,
struct sqlexd *, const struct sqlcxp *); void sqlcx2t(void **, unsigned long *,
struct sqlexd *, const struct sqlcxp *); void sqlbuft(void **, char *); void sqlgs2t(void **, char *);
// Forms Interface
static const int IAPSUCC = 0; static const int IAPFAIL = 1403; static const int IAPFTL = 535;
typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR; typedef struct { unsigned short len; unsigned char arr[1]; } varchar;
/* cud (compilation unit data) array */
static const short sqlcud0[] =
{10,4130,0,0,0,
5,0,0,1,0,0,32,31,0,0,0,0,0,1,0,
20,0,0,2,0,0,27,46,0,0,4,4,0,1,0,1,97,0,0,1,97,0,0,1,97,0,0,1,10,0,0,
51,0,0,3,0,0,32,53,0,0,0,0,0,1,0,
};
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqlda.h>
#include <sqlcpr.h>
/* EXEC SQL INCLUDE sqlca; */ /* * $Header: sqlca.h,v 1.3 1994/12/12 19:27:27 jbasu Exp $ sqlca.h */
/* Copyright (c) 1985,1986 by Oracle Corporation. */
/*
NAME
SQLCA : SQL Communications Area.
FUNCTION
Contains no code. Oracle fills in the SQLCA with status info
during the execution of a SQL stmt.
NOTES
If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA will be defined to have this storage class. For example:
#define SQLCA_STORAGE_CLASS extern
will define the SQLCA as an extern.
If the symbol SQLCA_INIT is defined, then the SQLCA will be statically initialized. Although this is not necessary in order to use the SQLCA, it is a good pgming practice not to have unitialized variables. However, some C compilers/OS's don't allow automatic variables to be init'd in this manner. Therefore, if you are INCLUDE'ing the SQLCA in a place where it would be an automatic AND your C compiler/OS doesn't allow this style of initialization, then SQLCA_INIT should be left undefined -- all others can define SQLCA_INIT if they wish.
If the symbol SQLCA_NONE is defined, then the SQLCA variable will not be defined at all. The symbol SQLCA_NONE should not be defined in source modules that have embedded SQL. However, source modules that have no embedded SQL, but need to manipulate a sqlca struct passed in as a parameter, can set the SQLCA_NONE symbol to avoid creation of an extraneous sqlca variable.
MODIFIED
jbasu 12/12/94 - Bug 217878: note this is an SOSD file
losborne 08/11/92 - No sqlca var if SQLCA_NONE macro set
Clare 12/06/84 - Ch SQLCA to not be an extern. Clare 10/21/85 - Add initialization. Bradbury 01/05/86 - Only initialize when SQLCA_INIT set Clare 06/12/86 - Add SQLCA_STORAGE_CLASS option.*/
#ifndef SQLCA
#define SQLCA 1
struct sqlca
{ /* ub1 */ char sqlcaid[8]; /* b4 */ long sqlabc; /* b4 */ long sqlcode; struct { /* ub2 */ unsigned short sqlerrml; /* ub1 */ char sqlerrmc[70]; } sqlerrm; /* ub1 */ char sqlerrp[8]; /* b4 */ long sqlerrd[6]; /* ub1 */ char sqlwarn[8]; /* ub1 */ char sqlext[8]; };
#ifndef SQLCA_NONE
#ifdef SQLCA_STORAGE_CLASS
SQLCA_STORAGE_CLASS struct sqlca sqlca
#else
struct sqlca sqlca
#endif
#ifdef SQLCA_INIT
#endif
/* end SQLCA */
/* EXEC SQL BEGIN DECLARE SECTION; */
#define UNAME_LEN 20
#define PWD_LEN 40
char username[UNAME_LEN]; char password[PWD_LEN]; char tns[20];
char err_msg[128];
size_t buf_len, msg_len;
/* EXEC SQL WHENEVER SQLERROR CONTINUE; */
printf("\n%s\n", msg);
buf_len = sizeof (err_msg);
sqlglm(err_msg, &buf_len, &msg_len);
printf("%.*s\n", msg_len, err_msg);
/* EXEC SQL ROLLBACK RELEASE; */ {
struct sqlexd sqlstm;
sqlstm.sqlvsn = 10; sqlstm.arrsiz = 0; sqlstm.sqladtp = &sqladt; sqlstm.sqltdsp = &sqltds; sqlstm.iters = (unsigned int )1; sqlstm.offset = (unsigned int )5; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0;
exit(EXIT_FAILURE);
}
void main()
{
char temp_char[32];
strcpy((char *) username, "vodev"); strcpy((char *) password, "vodev"); strcpy((char *) tns, "tns:dbprex");
printf("Before connect.\n");
/* EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n"); */
/* EXEC SQL CONNECT :username IDENTIFIED BY :password USING :tns; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 10; sqlstm.arrsiz = 4; sqlstm.sqladtp = &sqladt; sqlstm.sqltdsp = &sqltds; sqlstm.iters = (unsigned int )10; sqlstm.offset = (unsigned int )20; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = ( void *)username; sqlstm.sqhstl[0] = (unsigned int )20; sqlstm.sqhsts[0] = ( int )20; sqlstm.sqindv[0] = ( void *)0; sqlstm.sqinds[0] = ( int )0; sqlstm.sqharm[0] = (unsigned int )0; sqlstm.sqadto[0] = (unsigned short )0; sqlstm.sqtdso[0] = (unsigned short )0; sqlstm.sqhstv[1] = ( void *)password; sqlstm.sqhstl[1] = (unsigned int )40; sqlstm.sqhsts[1] = ( int )40; sqlstm.sqindv[1] = ( void *)0; sqlstm.sqinds[1] = ( int )0; sqlstm.sqharm[1] = (unsigned int )0; sqlstm.sqadto[1] = (unsigned short )0; sqlstm.sqtdso[1] = (unsigned short )0; sqlstm.sqhstv[2] = ( void *)tns; sqlstm.sqhstl[2] = (unsigned int )20; sqlstm.sqhsts[2] = ( int )20; sqlstm.sqindv[2] = ( void *)0; sqlstm.sqinds[2] = ( int )0; sqlstm.sqharm[2] = (unsigned int )0; sqlstm.sqadto[2] = (unsigned short )0; sqlstm.sqtdso[2] = (unsigned short )0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqphss = sqlstm.sqhsts; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqpins = sqlstm.sqinds; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlstm.sqpadto = sqlstm.sqadto; sqlstm.sqptdso = sqlstm.sqtdso;
printf("\nConnected to ORACLE as user: %s\n", username);
printf("\nG'day.\n\n\n");
/* Disconnect from ORACLE. */
/* EXEC SQL ROLLBACK WORK RELEASE; */ {
struct sqlexd sqlstm;
sqlstm.sqlvsn = 10; sqlstm.arrsiz = 4; sqlstm.sqladtp = &sqladt; sqlstm.sqltdsp = &sqltds; sqlstm.iters = (unsigned int )1; sqlstm.offset = (unsigned int )51; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0;
printf("\nDisconnected.\n");
exit(EXIT_SUCCESS);
}
Received on Mon Aug 23 1999 - 06:05:23 CDT