Обсуждение: ERROR

Поиск
Список
Период
Сортировка

ERROR

От
Ashok Chauhan
Дата:
# include <stdlib.h>
# include <libpq-fe.h>
int main()
{
        int feild;
        PGresult *result;
        PGconn *conn;
        conn = PQconnectdb("database");
        result = PQexec (conn, "select * from teblename");
        feild = PQntuples (result);
        printf("%d",feild);
        PQclear(result);
        PQfinish (conn);
        return (1);

}

I RUN THE ABOVE PROGRAM BUT IT GIVE SOME ERRORS THAT ARE FOLLOWS:-

/tmp/ccApFcdl.o: In function `main':
/tmp/ccApFcdl.o(.text+0x19): undefined reference to `PQconnectdb'
/tmp/ccApFcdl.o(.text+0x2f): undefined reference to `PQexec'
/tmp/ccApFcdl.o(.text+0x40): undefined reference to `PQntuples'
/tmp/ccApFcdl.o(.text+0x64): undefined reference to `PQclear'
/tmp/ccApFcdl.o(.text+0x72): undefined reference to `PQfinish'
collect2: ld returned 1 exit status

HELP ME

Re: ERROR

От
Bruno LEVEQUE
Дата:
Hi,

Change your connect line with :

conn = PQconnectdb("dbname='database'");


Bruno



Ashok Chauhan wrote:

># include <stdlib.h>
># include <libpq-fe.h>
>int main()
>{
>        int feild;
>        PGresult *result;
>        PGconn *conn;
>        conn = PQconnectdb("database");
>        result = PQexec (conn, "select * from teblename");
>        feild = PQntuples (result);
>        printf("%d",feild);
>        PQclear(result);
>        PQfinish (conn);
>        return (1);
>
>}
>
>I RUN THE ABOVE PROGRAM BUT IT GIVE SOME ERRORS THAT ARE FOLLOWS:-
>
>/tmp/ccApFcdl.o: In function `main':
>/tmp/ccApFcdl.o(.text+0x19): undefined reference to `PQconnectdb'
>/tmp/ccApFcdl.o(.text+0x2f): undefined reference to `PQexec'
>/tmp/ccApFcdl.o(.text+0x40): undefined reference to `PQntuples'
>/tmp/ccApFcdl.o(.text+0x64): undefined reference to `PQclear'
>/tmp/ccApFcdl.o(.text+0x72): undefined reference to `PQfinish'
>collect2: ld returned 1 exit status
>
>HELP ME
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
>

--
Bruno LEVEQUE
System Engineer
SARL NET6D
bruno.leveque@net6d.com
http://www.net6d.com



Re: ERROR

От
Stephan Szabo
Дата:
On Sat, 22 Nov 2003, Ashok Chauhan wrote:

>
> # include <stdlib.h>
> # include <libpq-fe.h>
> int main()
> {
>         int feild;
>         PGresult *result;
>         PGconn *conn;
>         conn = PQconnectdb("database");
>         result = PQexec (conn, "select * from teblename");
>         feild = PQntuples (result);
>         printf("%d",feild);
>         PQclear(result);
>         PQfinish (conn);
>         return (1);
>
> }
>
> I RUN THE ABOVE PROGRAM BUT IT GIVE SOME ERRORS THAT ARE FOLLOWS:-

Are you sure you're running the program when you get these errors as
opposed to compiling/linking?  The below look like linking errors you'd
get if you forgot to specify that you want to link with libpq.

If you're using gcc, you probably want at least -lpq and possibly a
-L<directory containing libpq.a> on the commandline.

>
> /tmp/ccApFcdl.o: In function `main':
> /tmp/ccApFcdl.o(.text+0x19): undefined reference to `PQconnectdb'
> /tmp/ccApFcdl.o(.text+0x2f): undefined reference to `PQexec'
> /tmp/ccApFcdl.o(.text+0x40): undefined reference to `PQntuples'
> /tmp/ccApFcdl.o(.text+0x64): undefined reference to `PQclear'
> /tmp/ccApFcdl.o(.text+0x72): undefined reference to `PQfinish'
> collect2: ld returned 1 exit status
>
> HELP ME
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>