Problem compiling program

Поиск
Список
Период
Сортировка
От mskott@image.dk (Martin Skøtt)
Тема Problem compiling program
Дата
Msg-id slrn7is3te.13o.mskott@jumbo.skott.dk
обсуждение исходный текст
Список pgsql-interfaces
Hello
I'm tryuing to learn to use libpq but it is quite difficult when you are
unable to compile programs as I am ;-)
I get this error when I compile the program in the buttom of this message:
/usr/local/pgsql/lib/libpq.so: undefined reference to `crypt'
I use this command on my Red Hat Linux 5.2 system when i try to compile:
gcc -I/usr/local/pgsql/include -o lj lj.c -L/usr/local/pgsql/lib -lpq

My program looks like this: (it was included in an article in Linux Journal)
#include <libpq-fe.h>
#include <strings.h>

int
main(int argc, char** argv)
{ PGconn* conn; PGresult* result; int i;  char* dbname = "tutorial"; conn = PQsetdb (NULL, NULL, NULL, NULL, dbname);
if(PQstatus(conn) == CONNECTION_BAD) {   fprintf(stderr,    "Connection to database '%S' failed.\n", dbname);
fprintf(stderr,"%S", PQerrorMessage(conn));   PQfinish(conn);   exit(1); }  result = PQexec(conn, "select * from
cities");if ((!result) || (PGRES_TUPLES_OK !=        PQresultStatus(result))) {   fprintf(stderr,    "Error sending
query.\nDetailed report: %s\n",    PQerrorMessage(conn));   PQfinish(conn);   exit(1); }
printf("name\t\tpopulation\taltitude\n\n");for (i = PQntuples(result)-1; i >= 0; i--) {   printf("%s\t%s\t\t%s\n",
PQgetvalue(result,i,0),  PQgetvalue(result,i,1), PQgetvalue(result,i,2)); }
 
}


-- 
Med venlig hilsen
Martin Sk�tt
mskott@image.dk


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Michael J Davis
Дата:
Сообщение: RE: [INTERFACES] error message
Следующее
От: Hugh Lawson
Дата:
Сообщение: Re: [INTERFACES] Field types (was Re: Return value of int)