Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

postgresql

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

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 error says 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:

$ 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?

like image 843
Mert Nuhoglu Avatar asked Dec 24 '14 12:12

Mert Nuhoglu


2 Answers

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.

sudo apt-get install libpq-dev

Or for Arch Linux:

sudo pacman -S postgresql-libs
like image 102
smishra Avatar answered Nov 13 '22 08:11

smishra


Adding to the previous answers, in case of errors even when libpq-dev is already installed. On Ubuntu 16.04 with installed libpq-dev, my libpq-fe.h was 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,

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

solved the situation.

like image 4
Adam Avatar answered Nov 13 '22 06:11

Adam