Thread: Remote PostgreSQL database - C/C++ program / Unix / Required Libraries
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. 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.
Me again. Sorry. This looks good too: "Building libpq Programs": http://www.postgresql.org/docs/9.1/static/libpq-build.html But what do I need to install on B? Best regards. -- View this message in context: http://postgresql.nabble.com/Remote-PostgreSQL-database-C-C-program-Unix-Required-Libraries-tp5828704p5828705.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
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.klaver@aklaver.com
Thank you for your answer :) > Adrian Klaver-4 wrote: > 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? Exactly. > Adrian Klaver-4 wrote: > If so you will need to either install the appropriate -dev package, say > libpq-dev and libpq I'd rather not to :/ but it's good to know I could do that. > Adrian Klaver-4 wrote: > or download the source and build only those parts. No. I'll not go into that. > There also seem to be libpqxx packages available. > > If not, you will need to explain further what you want? No. I thank you for your answer. I actually asked the question out of curiosity. (And also because I was working on a machine with no PostgreSQL installed. I was wondering if I had to install a whole PostgreSQL system or not). Best regards. -- View this message in context: http://postgresql.nabble.com/Remote-PostgreSQL-database-C-C-program-Unix-Required-Libraries-tp5828704p5828717.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
Re: Re: Remote PostgreSQL database - C/C++ program / Unix / Required Libraries
From
John R Pierce
Date:
On 11/30/2014 2:03 PM, Léa Massiot wrote: > I actually asked the question out of curiosity. > (And also because I was working on a machine with no PostgreSQL installed. I > was wondering if I had to install a whole PostgreSQL system or not). In the RH/CentOS/Fedora world, you CAN install just the runtime libraries and -devel packages (postgresqlXY-libs and -devel) to do C programming. I'm not sure if the debian/ubuntu packages have the same granularity. the 'whole postgres system' is really rather compact. a client-only user could well need not only the runtime library libpq.so and associated .h files, but also need pg_config, psql, pg_dump, pg_restore... about the only parts a client-only user wouldn't use would be the actual server 'postgres', and pg_ctl, these files combined are just a few megabytes. the full install of everything including contributed libraries is 34MB on my CentOS 6 64bit server.... -- john r pierce 37N 122W somewhere on the middle of the left coast
Re: Re: Remote PostgreSQL database - C/C++ program / Unix / Required Libraries
From
Reid Thompson
Date:
On Sun, 2014-11-30 at 12:51 -0700, Léa Massiot wrote: > Me again. Sorry. > > This looks good too: "Building libpq Programs": > http://www.postgresql.org/docs/9.1/static/libpq-build.html > > But what do I need to install on B? > > Best regards. > > > > -- > View this message in context: http://postgresql.nabble.com/Remote-PostgreSQL-database-C-C-program-Unix-Required-Libraries-tp5828704p5828705.html > Sent from the PostgreSQL - general mailing list archive at Nabble.com. > > > http://www.postgresql.org/docs/9.1/static/libpq-example.html