在Debian上安装RPostgreSQL时出现PostgreSQL 9.4 libpq fe.h错误

在Debian上安装RPostgreSQL时出现PostgreSQL 9.4 libpq fe.h错误,r,postgresql,R,Postgresql,我在Debian 7.6上安装了R(3.1.1)和PostgreSQL 9.4 I want to install RPostgreSQL but the compilation fails with the following error: In file included from RS-PQescape.c:7:0: RS-PostgreSQL.h:23:26: fatal error: libpq-fe.h:

我在Debian 7.6上安装了R(3.1.1)和PostgreSQL 9.4

I want to install RPostgreSQL but the compilation fails with the following error:
In file included from RS-PQescape.c:7:0:                                       
RS-PostgreSQL.h:23:26: fatal error: libpq-fe.h: No such file or directory      
compilation terminated.                                                        
make: *** [RS-PQescape.o] Error 1                                              
ERROR: compilation failed for package ‘RPostgreSQL’                            
* removing ‘/home/mert/R/x86_64-pc-linux-gnu-library/3.1/RPostgreSQL’          
前面的一个问题是,该文件包含在这里:

/usr/pgsql-9.3/include/libpq-fe.h
我在计算机上搜索了pgsql和libpq,但根本不存在这样的文件:

$ locate libpq                              
/usr/lib/postgresql/9.4/lib/libpqwalreceiver.so                                
/usr/lib/x86_64-linux-gnu/libpq.so.5                                           
/usr/lib/x86_64-linux-gnu/libpq.so.5.7                                         
/usr/share/doc/libpq5 

$ locate pgsql
/usr/lib/postgresql/9.4/lib/plpgsql.so                                         
/usr/share/postgresql/9.4/extension/plpgsql--1.0.sql                           
/usr/share/postgresql/9.4/extension/plpgsql--unpackaged--1.0.sql               
/usr/share/postgresql/9.4/extension/plpgsql.control  

你知道如何解决这个问题吗?

我可以使用以下方法在Ubuntu 14.04上安装RPostgreSQL:

system('gksudo "apt-get -y install postgresql-9.3 libpq-dev"')
install.packages("RPostgreSQL")

您的计算机上缺少libpq dev。打开命令提示符并使用apt get安装它。安装后,请尝试在R-Studio中安装RPostgreSQL

sudo apt-get install libpq-dev
或者对于Arch Linux:

sudo pacman -S postgresql-libs

添加到前面的答案中,即使已经安装了
libpq dev
也会出现错误。在安装了
libpq-dev
的Ubuntu 16.04上,我的
libpq-fe.h
位于
/usr/include/postgresql/
中,但R安装包函数仍然找不到它。从CRAN下载最新的RPostgreSQL版本后,我查看了它的配置文件,发现该文件夹被指定为postgres配置文件的可能位置,这让我相信这是一个权限问题,是的

sudo R CMD INSTALL RPostgreSQL_0.4-1.tar.gz 

解决了这个问题。

对于可能需要安装postgres devOn Ubuntu 14.04的头文件,
libpq fe.h
是包
libpq-dev
的一部分。