taocpp / taopq

C++ client library for PostgreSQL
Boost Software License 1.0
265 stars 40 forks source link

Building without Postgres installed? #30

Closed EliYk closed 4 years ago

EliYk commented 4 years ago

Hi,

Pardon my noobness, I'm trying to write a C++ postgres pipeline using taopq (the Python one is way too slow).

I saw that PostgreSQL itself is a dependency in CMakeLists.txt. However, it seems that libpq itself is much smaller - https://github.com/postgres/postgres/tree/master/src/backend/libpq

I built it by the instructions here, to receive a lipq.so.5.12

I also saw in the makefile a line that includes pg_config. Does this mean I still need postgres installed on the machine on which I'm using taopq? Is it somehow possible to avoid it, if I already have libpq.so?

Thanks, Eli

d-frey commented 4 years ago

I'm not an expert in this area either, but the intend was always to only require the client library, not the server. On my system, there are two packages I need to install to build taopq: The package for the library (libpq.so) and the -dev package so I get the headers and pg_config to build against that library. This is, of course, not the server.

Once you've build taopq and your executable using it, you could use that executable even when the -dev package is not installed, You'd only need the client library's package for that. Of course, using taopq will always require the -dev package as our headers include the libpq headers.

h5rdly commented 4 years ago

Can you elaborate about the dev package?

What files specifically are required?

(To get libpq.so, I went with the build suggested in this so question)

d-frey commented 4 years ago

I'm using Fedora 32, so I installed libpq and libpq-devel like this:

sudo dnf install libpq libpq-devel

and that's really all you need to do. Of course, I also installed the server as otherwise the client itself would be pretty useless. That is the postgresql-server package, but you shouldn't need it to compile taopq. That said, I haven't tested it, so maybe the CMakeLists.txt is not correct.

When a package is installed, you can list the installed files from a package with

rpm -ql libpq-devel

In this case, the headers like /usr/include/libpq-fe.h are the most important stuff to compile code against libpq.so.

ColinH commented 4 years ago

Also, building libpq yourself is very unusual, that's not something you would need to do under normal circumstances. To build a client application you'll need the libpq (libraries) and libpq-devel (headers) packages, to deploy a client application you'll only need the libpq package, and of course somewhere you'll need the actual server to connect your client to...

ColinH commented 4 years ago

@EliYk Did you manage to sort out the packages required for compiling?