#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","cloud","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;
}

编译问题:http://www.cnblogs.com/xfiver/archive/2012/02/17/2355642.html

gcc编译:gcc -I /usr/include/postgresql/ postgresql.c -o pgsql -lpq

 

 

yum install postgresql-devel

如果没有include 和 lib 两个目录......
说明你还没装开发devel包
redhat上应该有其开发包

相关文章:

  • 2021-08-08
  • 2021-05-19
  • 2022-01-21
  • 2021-06-14
  • 2021-11-26
  • 2021-12-25
  • 2021-06-21
  • 2022-03-06
猜你喜欢
  • 2021-10-21
  • 2021-12-09
  • 2021-12-16
  • 2021-11-04
  • 2021-11-30
  • 2021-09-24
  • 2021-10-10
相关资源
相似解决方案