Problem compiling program - Mailing list pgsql-interfaces

From mskott@image.dk (Martin Skøtt)
Subject Problem compiling program
Date
Msg-id slrn7is3te.13o.mskott@jumbo.skott.dk
Whole thread Raw
List 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 by date:

Previous
From: Michael J Davis
Date:
Subject: RE: [INTERFACES] error message
Next
From: Hugh Lawson
Date:
Subject: Re: [INTERFACES] Field types (was Re: Return value of int)