Re: Remote PostgreSQL database - C/C++ program / Unix / Required Libraries

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Léa Massiot <lmhelp1(at)orange(dot)fr>, pgsql-general(at)postgresql(dot)org
Subject: Re: Remote PostgreSQL database - C/C++ program / Unix / Required Libraries
Date: 2014-11-30 20:27:35
Message-ID: 547B7DB7.6080407@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/30/2014 11:44 AM, Léa Massiot wrote:
> Hello and thank you for reading my post.
>
> I would like to write a C/C++ program which targets a remote PostgreSQL
> database.
> I don't know what to install, which libraries to link to in this program.
>
> In more details:
>
> Given:
> 1.1) a PostgreSQL database "db" on a machine A,
> 1.2) a machine B.
>
> I would like to write a program (which is very classical) and run it on B:
> 2.1) connect to the remote PostgreSQL database "db" ;
> 2.2) "SELECT" one row in a table of this database ;
> 2.3) "UPDATE" this row.
>
> B is a machine running a Debian Squeeze OS.
> The program has to be written in C/C++.
>
> Below are my questions:
> - What libraries/PostgreSQL programming environment do I have to install on
> B to be able to write this program?
> - Does a whole PostgreSQL system have to be installed on B?
> - Nota: I do not want to install a Debian package: I usually install
> PostgreSQL from the sources.
>
> This tutorial (PostgreSQL - C/C++ Interface - Using libpqxx library) looks
> interesting:
> http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
> But after running "./configure" I get the following error:
> ----------------------------------------------------------------------------------
> configure: error:
> PostgreSQL configuration script pg_config not found. Make sure this is in
> your
> command path before configuring. Without it, the configure script has no
> way to
> find the right location for the libpq library and its headers.
> ----------------------------------------------------------------------------------
> So, I'm wondering what are the prerequisites for this installation...
>
> Nota: I would like to insist on the fact that there is no PostgreSQL related
> material on B.

If you plan on using Postgres libraries that is going to be impossible.
My guess is you want is way to install the minimum necessary to write a
C/C++ file against the Postgres libraries.

Is this correct?

If so you will need to either install the appropriate -dev package, say
libpq-dev and libpq or download the source and build only those parts.
There also seem to be libpqxx packages available.

If not, you will need to explain further what you want?

>
> Best regards.
>
>
>
> --
> View this message in context: http://postgresql.nabble.com/Remote-PostgreSQL-database-C-C-program-Unix-Required-Libraries-tp5828704.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Woodbridge 2014-11-30 21:05:02 to_char(timestamp, format) is changing the year!
Previous Message Davide S 2014-11-30 19:54:32 JSON_AGG produces extra square brakets