问题
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.
回答1:
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:
- download the source code archive, for example https://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2
- unpack into a build directory:
tar xjf ~/Downloads/postgresql-9.4.1.tar.bz2
apt-get install libssl-dev
if it's not installed already- cd into it and configure:
cd postgresql-9.4.1; ./configure --with-openssl --without-readline
- Assuming configure succeeds, cd into
src/interfaces/libpq
and runmake
- 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
.
回答2:
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.)
来源:https://stackoverflow.com/questions/29803847/how-to-download-compile-install-only-the-libpq-source-on-a-server-that-does-n