Connect Linux C to the PostgreSQL database

Source: Internet
Author: User
# 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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.