Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

undefined reference to `ECPGconnect'

Status
Not open for further replies.

boaconstrictor

Programmer
Feb 21, 2002
19
CH
Hy there,
I have just started to program my first embedded sql program. I could generate the c file, but when I try to link the file I get always the errormassage mentioned in the title.

Does anybody have an idea what the problem could be?

I am using Linux Mandrake and the KDevelop Version 3.0.3.

Here is the c-file:
Code:
/*##################################################*/
/* Processed by ecpg (2.9.0) */
/* These three include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#line 1 &quot;update.pgc&quot;
int main()
{
	{ ECPGconnect(__LINE__, &quot;test&quot; , NULL,NULL , NULL, 1); }
#line 3 &quot;update.pgc&quot;

	{ ECPGdo(__LINE__, NULL, &quot;update number set name  = 'The Answer to the Ultimate Question'  where intval  = 42&quot;, ECPGt_EOIT, ECPGt_EORT);}
#line 6 &quot;update.pgc&quot;

	{ ECPGtrans(__LINE__, NULL, &quot;commit&quot;);}
#line 7 &quot;update.pgc&quot;

	{ ECPGdisconnect(__LINE__, &quot;ALL&quot;);}
#line 8 &quot;update.pgc&quot;

	return 0;
}
/*####################################################*/

...and the makefile:
Code:
/*####################################################*/
# Base directories for the PostgreSQL installation
INC = /usr/include/pgsql

CFLAGS = -I$(INC)
LDLIBS = -lpq


update:	update.o
	gcc $(LDLIBS) -o update update.o

update.o:	update.c
	gcc -c $(CFLAGS) update.c
/*###################################################*/
 
Hi boaconstrictor,

I think you have to pre-compile it with the ecpg command. Then compile it with the cc or gcc...

Here is a sample of my makefile.

ENV = /home/aevangel
SRC1 = $(ENV)/source/Database/
INC = $(ENV)/include
PGINC = /usr/include/pgsql
LIB = /usr/lib/pgsql
OBJ = $(ENV)/obj/
BIN = $(ENV)/source/

OBJS = $(OBJ)sampledb.o

$(BIN)SampleDB : $(OBJS)
cc -o $@ $(OBJS) -I$(INC) -I$(PGINC) -L$(LIB) -lecpg -lpq

$(OBJ)sampledb.o : $(SRC1)sampledb.pgc
echo &quot;Compiling....&quot; $@
ecpg -o$(SRC1)sampledb.c -I$(PGINC) $(SRC1)sampledb.pgc
cc -g -c $(SRC1)sampledb.c -I$(INC) -I$(PGINC) -L$(LIB) -o$@

Hope this helps.

raisin96
 
Thanks to all for your answers!!!

The program has been precompiled with the ecpg-command. The problem was the negligence of the &quot;-lecpg&quot; - statement in the makefile.

Now it works well!!

kind regards boaconstrictor
[2thumbsup][2thumbsup][2thumbsup][2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top