How to download, compile & install ONLY the libpq source on a server that DOES NOT have PostgreSQL installed

半城伤御伤魂 提交于 2019-12-11 09:27:24

问题


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:

  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.




回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!