Home » Developer & Programmer » Precompilers, OCI & OCCI » Pro*C -- Linker Error: Undefined symbol _sqlcxt in module
icon11.gif  Pro*C -- Linker Error: Undefined symbol _sqlcxt in module [message #211340] Thu, 28 December 2006 01:09 Go to next message
umrigar_kunal
Messages: 10
Registered: December 2006
Location: pune
Junior Member
hi all,

#I m trying a Pro C program.
#I m using Oracle9i DB preCompilier..
#The file temp.pc contains..

/////////////////temp.pc starts///////////////////////////////

#include <stdio.h>
#include <string.h>


EXEC SQL INCLUDE sqlca.h ;


void main()
{


EXEC SQL BEGIN DECLARE SECTION;

char *url = "QMRS.SUTRASYSTEMS.COM";
char *user = "qmrs";
char *pwd = "qmrs";
char data[30];



EXEC SQL END DECLARE SECTION;

EXEC SQL CONNECT :user IDENTIFIED BY :pwd USING :url;

EXEC SQL SELECT VAL INTO :data FROM TMP;



printf("val: %s\n", data);


}
/////////////////temp.pc ends///////////////


#The above file precompiles properly "temp.c" file is generated.

#I m using Turbo C for Compiling the temp.c file.
compiles fine but gives a linking error

Linker Error: Undefined symbol _sqlcxt in module

#i have included the libraries from {ORACLE_HOME}\precomp\lib\msvc\oraSQL9.lib
in the lib dir of TCC ie D:\TCC\LIB

Still the problem persists please help me out if any one has a soln


thanks in advance



[Updated on: Fri, 29 December 2006 01:06]

Report message to a moderator

Re: Pro*C -- Linker Error: Undefined symbol _sqlcxt in module [message #211358 is a reply to message #211340] Thu, 28 December 2006 03:20 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Hi

I think your problem is that you are using Turbo C.
Try another compiler

Read this

Pro*C Introduction
Re: Pro*C -- Linker Error: Undefined symbol _sqlcxt in module [message #211363 is a reply to message #211340] Thu, 28 December 2006 03:28 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Im not a C programmer, so I leave this "open".
But it seems that the only supported compiler for Windows is MSVC++

Hope that helps
Re: Pro*C -- Linker Error: Undefined symbol _sqlcxt in module [message #211508 is a reply to message #211340] Fri, 29 December 2006 01:12 Go to previous messageGo to next message
umrigar_kunal
Messages: 10
Registered: December 2006
Location: pune
Junior Member
Thanks Tahpush For the Help..

i was Finaaly able to run it with few Changes..

1. Used Visual Studio C++ IDE
2. Renamed File genereted from C to CPP
3. Made changes in the code as shown in code below in RED color
4. Used External Libtrary {ORACLE_HOME}\precomp\lib\msvc\oraSQL9.lib for building..


//////////////////temp.cpp////////////////

/* 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[49];
};
static const struct sqlcxp sqlfpn =
{
48,
"C:\\Documents and Settings\\kunalu\\Desktop\\temp.pc"
};


static unsigned long sqlctx = 1696417141;


static struct sqlexd {
unsigned int sqlvsn;
unsigned int arrsiz;
unsigned int iters;
unsigned int offset;
unsigned short selerr;
unsigned short sqlety;
unsigned int occurs;
const short *cud;
unsigned char *sqlest;
const char *stmt;
sqladts *sqladtp;
sqltdss *sqltdsp;
void **sqphsv;
unsigned int *sqphsl;
int *sqphss;
void **sqpind;
int *sqpins;
unsigned int *sqparm;
unsigned int **sqparc;
unsigned short *sqpadto;
unsigned short *sqptdso;
void *sqhstv[4];
unsigned int sqhstl[4];
int sqhsts[4];
void *sqindv[4];
int sqinds[4];
unsigned int sqharm[4];
unsigned int *sqharc[4];
unsigned short sqadto[4];
unsigned short sqtdso[4];
} sqlstm = {10,4};

/* SQLLIB Prototypes */
extern "C" void sqlcxt (void **, unsigned long *,
struct sqlexd *, const struct sqlcxp *);
extern "C" void sqlcx2t(void **, unsigned long *,
struct sqlexd *, const struct sqlcxp *);
extern "C" void sqlbuft(void **, char *);
extern "C" void sqlgs2t(void **, char *);
extern "C" void sqlorat(void **, unsigned long *, void *);

/* Forms Interface */
static const int IAPSUCC = 0;
static const int IAPFAIL = 1403;
static const int IAPFTL = 535;
extern void sqliem(char *, int *);

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,832,0,0,
5,0,0,1,0,0,27,23,0,0,4,4,0,1,0,1,97,0,0,1,97,0,0,1,97,0,0,1,10,0,0,
36,0,0,2,30,0,4,25,0,0,1,0,0,1,0,2,97,0,0,
};


#include <stdio.h>
#include <string.h>


/* EXEC SQL INCLUDE sqlca.h ;
*/
/*
* $Header: sqlca.h,v 1.3 1994/12/12 19:27:27 jbasu Exp $ sqlca.h
*/

/* Copyright (c) 1985,1986, 1998 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
**************************************************************
*** ***
*** This file is SOSD. Porters must change the data types ***
*** appropriately on their platform. See notes/pcport.doc ***
*** for more information. ***
*** ***
**************************************************************

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
lvbcheng 07/31/98 - long to int
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 */ int sqlabc;
/* b4 */ int sqlcode;
struct
{
/* ub2 */ unsigned short sqlerrml;
/* ub1 */ char sqlerrmc[70];
} sqlerrm;
/* ub1 */ char sqlerrp[8];
/* b4 */ int 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
= {
{'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
sizeof(struct sqlca),
0,
{ 0, {0}},
{'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
}
#endif
;
#endif

#endif

/* end SQLCA */



void main()
{


/* EXEC SQL BEGIN DECLARE SECTION; */


char *url = "QMRS.SUTRASYSTEMS.COM";
char *user = "qmrs";
char *pwd = "qmrs";
char data[30];



/* EXEC SQL END DECLARE SECTION; */


/* EXEC SQL CONNECT :user IDENTIFIED BY :pwd USING :url; */

{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 10;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.iters = (unsigned int )10;
sqlstm.offset = (unsigned int )5;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)256;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqhstv[0] = ( void *)user;
sqlstm.sqhstl[0] = (unsigned int )0;
sqlstm.sqhsts[0] = ( int )0;
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 *)pwd;
sqlstm.sqhstl[1] = (unsigned int )0;
sqlstm.sqhsts[1] = ( int )0;
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 *)url;
sqlstm.sqhstl[2] = (unsigned int )0;
sqlstm.sqhsts[2] = ( int )0;
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;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}



/* EXEC SQL SELECT VAL INTO :data FROM TMP; */

{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 10;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.stmt = "select VAL into :b0 from TMP ";
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )36;
sqlstm.selerr = (unsigned short)1;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)256;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqhstv[0] = ( void *)data;
sqlstm.sqhstl[0] = (unsigned int )30;
sqlstm.sqhsts[0] = ( int )0;
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.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;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}





printf("val: %s\n", data);



}
///////////////////////temp.cpp ends//////////////////




Cheers!!!!!!!!!!
Re: Pro*C -- Linker Error: Undefined symbol _sqlcxt in module [message #211523 is a reply to message #211508] Fri, 29 December 2006 02:25 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Exellent , Glad it worked out for you Smile
Re: Pro*C -- Linker Error: Undefined symbol _sqlcxt in module [message #557107 is a reply to message #211523] Fri, 08 June 2012 22:53 Go to previous message
SanthanaTodatry
Messages: 1
Registered: June 2012
Junior Member
Problem:

I am building my application in Red Hat Linux. My Pro*C code compiles fine but while linking I was getting the following error:

undefined reference to `sqlcxt(void**, unsigned int*, sqlexd*, sqlcxp const*)'

Solution:

Using the tip from umrigar_kunal above, I edited the .c file, and inserted "C" as follows:

/* SQLLIB Prototypes */
extern "C" void sqlcxt (void **, unsigned int *, struct sqlexd *, const struct sqlcxp *);
extern "C" void sqlcx2t(void **, unsigned int *, struct sqlexd *, const struct sqlcxp *);
extern "C" void sqlbuft(void **, char *);
extern "C" void sqlgs2t(void **, char *);
extern "C" void sqlorat(void **, unsigned int *, void *);

Now, I am able to link and create the executable.

Thanks umrigar_kunal!!!

Is there a Pro*C flag that can create these extern declarations with the "C" literal? I wonder.
Previous Topic: Print run time value
Next Topic: Pro*C XML sample
Goto Forum:
  


Current Time: Sat Dec 14 14:37:31 CST 2024