undefined reference to `ECPGconnect'
undefined reference to `ECPGconnect'
(OP)
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:
/*##################################################*/
/* 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 "update.pgc"
int main()
{
{ ECPGconnect(__LINE__, "test" , NULL,NULL , NULL, 1); }
#line 3 "update.pgc"
{ ECPGdo(__LINE__, NULL, "update number set name = 'The Answer to the Ultimate Question' where intval = 42", ECPGt_EOIT, ECPGt_EORT);}
#line 6 "update.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
#line 7 "update.pgc"
{ ECPGdisconnect(__LINE__, "ALL");}
#line 8 "update.pgc"
return 0;
}
/*####################################################*/
...and the makefile:
/*####################################################*/
# 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
/*###################################################*/
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:
/*##################################################*/
/* 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 "update.pgc"
int main()
{
{ ECPGconnect(__LINE__, "test" , NULL,NULL , NULL, 1); }
#line 3 "update.pgc"
{ ECPGdo(__LINE__, NULL, "update number set name = 'The Answer to the Ultimate Question' where intval = 42", ECPGt_EOIT, ECPGt_EORT);}
#line 6 "update.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
#line 7 "update.pgc"
{ ECPGdisconnect(__LINE__, "ALL");}
#line 8 "update.pgc"
return 0;
}
/*####################################################*/
...and the makefile:
/*####################################################*/
# 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
/*###################################################*/
RE: undefined reference to `ECPGconnect'
I've never worked with ecpg - Embedded SQL in C and I'm not be able to find much about it in the postgres doc. However, maybe the following link will help.
http://www.postgresql.org/idocs/index.php?ecpg.html
Leland F. Jackson, CPA
Software - Master (TM)
https://www.smvfp.com
Nothing Runs Like the Fox
RE: undefined reference to `ECPGconnect'
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 "Compiling...." $@
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
RE: undefined reference to `ECPGconnect'
The program has been precompiled with the ecpg-command. The problem was the negligence of the "-lecpg" - statement in the makefile.
Now it works well!!
kind regards boaconstrictor