# Include <stdio. h> # Include <Stdlib. h> # Include <Libpq-fe.h> # Include < String . H> Int Main () {pgconn * Conn; Const Char * Conninfo = " Host = localhost dbname = cloud user = cloud Password = cloud " ; // Char conninfo [100]; // Sprintf (conninfo, "dbname = % s user = % s Password = % s", "Cloud "); Conn = Pqconnectdb (conninfo ); If (Pqstatus (conn) = Connection_bad) {fprintf (stderr, " Connection to % s failed " , Conninfo); pqerrormessage (conn );} Else Printf ( " Connection OK " ); Pqfinish (conn ); Return 0 ;}
Compilation problem: http://www.cnblogs.com/xfiver/archive/2012/02/17/2355642.html
GCC Compilation: gcc-I/usr/include/PostgreSQL. C-o pgsql-lpq
Yum install postgresql-devel
If there are no include and Lib directories ...... It indicates that you have not installed and developed the devel package. The RedHat should have its Development Kit |