How to download, compile & install ONLY the libpq

2019-08-11 16:41发布

How can I download, compile, make & install ONLY the libpq source on a server (Ubuntu) that DOES NOT have PostgreSQL installed?

I have found the libpq source here. However it does NOT seem to be separable from the entire PostgreSQL. Thanks in advance.

I DO NOT want to install the entire PostgreSQL. I want to use libpq as a C interface to PostgreSQL on a DIFFERENT server (also Ubuntu) that DOES have it installed.

I also found this old link which indicates that the above is POSSIBLE but not HOW to do it.

2条回答
放荡不羁爱自由
2楼-- · 2019-08-11 17:28

Besides downloading and configuration, the steps are:

cd src/interfaces/libpq; make; make install; cd -
cd src/bin/pg_config; make install; cd -
cd src/backend; make generated-headers; cd -
cd src/include; make install; cd -

These steps will give you the library and headers of libpq, and a binary called pg_config, and all postgresql backend headers, so that you could compile things like libpqxx correctly.

(I've just tested with postgresql-9.6.5.)

查看更多
相关推荐>>
3楼-- · 2019-08-11 17:31

I have found the libpq source here. However it does NOT seem to be separable from the entire PostgreSQL.

It has to be configured with the entire source tree because that's what generates the necessary Makefile parts. But once configured, make && make install can run inside the src/interfaces/libpq directory alone, and the rest being left out completely.

In steps:

  1. download the source code archive, for example https://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2
  2. unpack into a build directory: tar xjf ~/Downloads/postgresql-9.4.1.tar.bz2
  3. apt-get install libssl-dev if it's not installed already
  4. cd into it and configure: cd postgresql-9.4.1; ./configure --with-openssl --without-readline
  5. Assuming configure succeeds, cd into src/interfaces/libpq and run make
  6. still in the libpq directory, run make install as root: sudo make install.

That will install into /usr/local/pgsql and subdirectories as a library independent and insulated from the one packaged in Ubuntu if it happens to be installed. To install it elsewhere, specify the location with the --prefix option to configure.

查看更多
登录 后发表回答