Обсуждение: error in code

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

error in code

От
Ashok Chauhan
Дата:
hi
*********************************
# include <stdio.h>
# include <stdlib.h>
# include </usr/include/libpq-fe.h>
# include </usr/include/libpq/libpq-fs.h>

int main()
{
        PGresult *result;
        PGconn *conn;
        int feild;
        conn = PQconnectdb ("ashok");
        result = PQexec (conn, "select * from bill");
        feild = PQntuples (result);
        printf("%d",feild);
        PQclear (result);
        PQfinish (conn);
        printf("hello");
        return 1;


}

I make the following code with the make command but give the following
the errors:-

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

plz help me.

Re: error in code

От
Oliver Elphick
Дата:
On Mon, 2003-12-08 at 13:55, Ashok Chauhan wrote:
> I make the following code with the make command but give the following
> the errors:-
>
> /tmp/ccUWs9W9.o: In function `main':
> /tmp/ccUWs9W9.o(.text+0x19): undefined reference to `PQconnectdb'
> /tmp/ccUWs9W9.o(.text+0x2f): undefined reference to `PQexec'
> /tmp/ccUWs9W9.o(.text+0x40): undefined reference to `PQntuples'
> /tmp/ccUWs9W9.o(.text+0x64): undefined reference to `PQclear'
> /tmp/ccUWs9W9.o(.text+0x72): undefined reference to `PQfinish'
> collect2: ld returned 1 exit status
> make: *** [aa] Error 1

These are link errors.  You need to add -lpq to the link command line
(and possibly -Lpath for the libpq library path as well).

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "For I am the LORD your God; ye shall therefore
      sanctify yourselves, and ye shall be holy; for I am
      holy."          Leviticus 11:44