如何下载,编译和在没有安装PostgreSQL的服务器上只安装libpq源

时间:2015-04-22 16:38:47

标签: postgresql install libpq

我如何下载,编译,制作和播放只安装没有安装PostgreSQL的服务器(Ubuntu)上的libpq源?

我找到了libpq源here。但它似乎与整个PostgreSQL无法分离。提前谢谢。

我不想安装整个PostgreSQL。我想在一个安装了它的DIFFERENT服务器(也是Ubuntu)上使用libpq作为PostgreSQL的C接口。

我还发现this old link表示上述情况可能但不是如何做到这一点。

2 个答案:

答案 0 :(得分:5)

  

我在这里找到了libpq源代码。但它似乎与整个PostgreSQL无法分离。

必须使用整个源树配置它,因为这是生成必要的Makefile部分的原因。但一旦配置,make&amp;&amp; <{1}}可以单独在make install目录中运行,其余部分完全省略。

分步骤:

  1. 下载源代码存档,例如https://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2
  2. 解压缩到构建目录:src/interfaces/libpq
  3. tar xjf ~/Downloads/postgresql-9.4.1.tar.bz2如果尚未安装
  4. cd进入并配置:apt-get install libssl-dev
  5. 假设配置成功,请执行cd postgresql-9.4.1; ./configure --with-openssl --without-readline并运行src/interfaces/libpq
  6. 仍然在make目录中,以root身份运行make install:libpq
  7. 这将作为独立的库安装到sudo make install和子目录中,如果碰巧安装它,则与Ubuntu中打包的库绝缘。要将其安装在其他位置,请使用/usr/local/pgsql选项--prefix指定位置。

答案 1 :(得分:0)

除下载和配置外,步骤如下:

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 -

这些步骤将为您提供libpq的库和标头,以及名为pg_config的二进制文件和所有postgresql后端标头,以便您可以正确编译libpqxx之类的内容。

(我刚用postgresql-9.6.5测试过。)