×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

undefined reference to `ECPGconnect'

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
/*###################################################*/

RE: undefined reference to `ECPGconnect'

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 "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'

(OP)
Thanks to all for your answers!!!

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close