Thread: Problem in using C API - libpq

Problem in using C API - libpq

From
Shwe Yee Than
Date:
Hello,

I´ve got a problem when trying to access Postgresql through C language. I've included "libpq-fe.h" as a header file in the C program.
When I compile it, I got the following errors:
[srb@fsktm src]$ gmake
alpha1.o(.text+0x297c6):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12726: undefined reference to `PQstatus'
alpha1.o(.text+0x297f5):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12729: undefined reference to `PQerrorMessage'
alpha1.o(.text+0x2986f):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12741: undefined reference to `PQexec'
alpha1.o(.text+0x29886):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12743: undefined reference to `PQresultStatus'
alpha1.o(.text+0x298b2):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12746: undefined reference to `PQclear'
alpha1.o(.text+0x298c3):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12747: undefined reference to `PQfinish'
alpha1.o(.text+0x298e8):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12751: undefined reference to `PQntuples'
alpha1.o(.text+0x2990c):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12752: undefined reference to `PQgetvalue'
alpha1.o(.text+0x29935):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12754: undefined reference to `PQclear'
alpha1.o(.text+0x29946):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12756: undefined reference to `PQfinish'
collect2: ld returned 1 exit status
gmake: *** [etd.cgi] Error 1

Ayone can help me?
Thanks in advance

Regards,
Shwe


Looking for last minute shopping deals? Find them fast with Yahoo! Search.

Re: Problem in using C API - libpq

From
Ben
Date:
Including the header is not enough.... you must also link your binary against the library.

On Feb 11, 2008, at 9:52 PM, Shwe Yee Than wrote:

Hello,

I´ve got a problem when trying to access Postgresql through C language. I've included "libpq-fe.h" as a header file in the C program.
When I compile it, I got the following errors:
[srb@fsktm src]$ gmake
alpha1.o(.text+0x297c6):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12726: undefined reference to `PQstatus'
alpha1.o(.text+0x297f5):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12729: undefined reference to `PQerrorMessage'
alpha1.o(.text+0x2986f):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12741: undefined reference to `PQexec'
alpha1.o(.text+0x29886):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12743: undefined reference to `PQresultStatus'
alpha1.o(.text+0x298b2):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12746: undefined reference to `PQclear'
alpha1.o(.text+0x298c3):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12747: undefined reference to `PQfinish'
alpha1.o(.text+0x298e8):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12751: undefined reference to `PQntuples'
alpha1.o(.text+0x2990c):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12752: undefined reference to `PQgetvalue'
alpha1.o(.text+0x29935):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12754: undefined reference to `PQclear'
alpha1.o(.text+0x29946):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12756: undefined reference to `PQfinish'
collect2: ld returned 1 exit status
gmake: *** [etd.cgi] Error 1

Ayone can help me?
Thanks in advance

Regards,
Shwe


Looking for last minute shopping deals? Find them fast with Yahoo! Search.

Re: Problem in using C API - libpq

From
Shwe Yee Than
Date:
Could you please tell me how to do so? Thanks.

Ben <bench@silentmedia.com> wrote:
Including the header is not enough.... you must also link your binary against the library.

On Feb 11, 2008, at 9:52 PM, Shwe Yee Than wrote:

Hello,

I´ve got a problem when trying to access Postgresql through C language. I've included "libpq-fe.h" as a header file in the C program.
When I compile it, I got the following errors:
[srb@fsktm src]$ gmake
alpha1.o(.text+0x297c6):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12726: undefined reference to `PQstatus'
alpha1.o(.text+0x297f5):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12729: undefined reference to `PQerrorMessage'
alpha1.o(.text+0x2986f):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12741: undefined reference to `PQexec'
alpha1.o(.text+0x29886):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12743: undefined reference to `PQresultStatus'
alpha1.o(.text+0x298b2):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12746: undefined reference to `PQclear'
alpha1.o(.text+0x298c3):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12747: undefined reference to `PQfinish'
alpha1.o(.text+0x298e8):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12751: undefined reference to `PQntuples'
alpha1.o(.text+0x2990c):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12752: undefined reference to `PQgetvalue'
alpha1.o(.text+0x29935):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12754: undefined reference to `PQclear'
alpha1.o(.text+0x29946):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12756: undefined reference to `PQfinish'
collect2: ld returned 1 exit status
gmake: *** [etd.cgi] Error 1

Ayone can help me?
Thanks in advance

Regards,
Shwe


Looking for last minute shopping deals? Find them fast with Yahoo! Search.



Looking for last minute shopping deals? Find them fast with Yahoo! Search.

Re: Problem in using C API - libpq

From
"Pavel Stehule"
Date:
Hello,

you have to use switch -lpq

http://www.postgresql.org/docs/8.3/static/libpq-build.html

Regards
Pavel Stehule


On 12/02/2008, Shwe Yee Than <shweyeesyt@yahoo.com> wrote:
> Hello,
>
>
> I´ve got a problem when trying to access Postgresql through C language. I've
> included "libpq-fe.h" as a header file in the C program.
>  When I compile it, I got the following errors: [srb@fsktm src]$ gmake
> alpha1.o(.text+0x297c6):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12726:
> undefined reference to `PQstatus'
> alpha1.o(.text+0x297f5):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12729:
> undefined reference to `PQerrorMessage'
> alpha1.o(.text+0x2986f):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12741:
> undefined reference to `PQexec'
> alpha1.o(.text+0x29886):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12743:
> undefined reference to `PQresultStatus'
> alpha1.o(.text+0x298b2):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12746:
> undefined reference to `PQclear'
> alpha1.o(.text+0x298c3):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12747:
> undefined reference to `PQfinish'
> alpha1.o(.text+0x298e8):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12751:
> undefined reference to `PQntuples'
> alpha1.o(.text+0x2990c):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12752:
> undefined reference to `PQgetvalue'
> alpha1.o(.text+0x29935):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12754:
> undefined reference to `PQclear'
> alpha1.o(.text+0x29946):/home/srb/SRB3_4_2/mySRB/src/alpha1.c:12756:
> undefined reference to `PQfinish'
>  collect2: ld returned 1 exit status
>  gmake: *** [etd.cgi] Error 1
>
>  Ayone can help me?
>  Thanks in advance
>
>  Regards,
>  Shwe
>
>
>  ________________________________
> Looking for last minute shopping deals? Find them fast with Yahoo! Search.
>
>