使用 PostgreSQL 9.4 libpq-fe.h 错误在 Debian 上安装 RPostgreSQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27637110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:43:27  来源:igfitidea点击:

Install RPostgreSQL on Debian with PostgreSQL 9.4 libpq-fe.h Error

rpostgresql

提问by Mert Nuhoglu

I have R (3.1.1) and PostgreSQL 9.4 installed on Debian 7.6.

我在 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'          

A previous question on this errorsays that the file is included here:

关于此错误的先前问题表示该文件包含在此处:

/usr/pgsql-9.3/include/libpq-fe.h

I searched on my computer for pgsql and libpq but no such file exists at all:

我在我的电脑上搜索了 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  

Do you have any idea on how to solve this problem?

你对如何解决这个问题有什么想法吗?

回答by smishra

You are missing libpq-dev on your machine. Open a command prompt and install it using apt-get. Once installed try installing RPostgreSQL in R-Studio.

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

sudo apt-get install libpq-dev

Or for Arch Linux:

或者对于 Arch Linux:

sudo pacman -S postgresql-libs

回答by Adam

Adding to the previous answers, in case of errors even when libpq-devis already installed. On Ubuntu 16.04 with installed libpq-dev, my libpq-fe.hwas sitting in /usr/include/postgresql/but the R install packages function still could not find it. After downloading the latest RPostgreSQL build from CRAN, I looked at its configure file and saw that this folder was specified in it as a likely location for the postgres configuration files which led me to believe that it was a permissions problem, and, yes,

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

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

solved the situation.

解决了情况。

回答by dnlbrky

I was able to install RPostgreSQL on Ubuntu 14.04 using the following:

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

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