在Ubuntu下安装RPostgreSQL

在Windows上安装RPostgreSQL非常简单,

install.packages("RPostgreSQL")

但同样都命令在Ubuntu(Linux)环境下就会遇到如下错误,

checking for "/libpq-fe.h"... no
configure: creating ./config.status
config.status: creating src/Makevars
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RS-DBI.c -o RS-DBI.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RS-PQescape.c -o RS-PQescape.o
/usr/lib/R/etc/Makeconf:132: recipe for target 'RS-PQescape.o' failed
Warning in install.packages :
  installation of package ‘RPostgreSQL’ had non-zero exit status

那是因为缺少PostgreSQL开发库,

sudo apt-get install libpq-dev

P.S.

R的PostgreSQL读写库有两个,一个是RPostgreSQL,另外一个是rpg,都依赖libpq-dev。