No such file error libpq-fe.h when installing PostgreSQL package for R on Linux

Abe*_*ejo 2 linux postgresql r

On R, I was trying to install the PostgreSQL package called the RPostgreSQL.

I tried to install it by issuing the statement in the command-line like so:

R
Run Code Online (Sandbox Code Playgroud)

命令行语句显示输出:

R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>
Run Code Online (Sandbox Code Playgroud)

然后我尝试安装软件包

install.packages("RPostgreSQL")
Run Code Online (Sandbox Code Playgroud)

然后安装失败并显示此错误消息

In file included from RS-PQescape.c:7:0:
RS-PostgreSQL.h:23:14: fatal error: libpq-fe.h: No such file or directory
 #    include "libpq-fe.h"
              ^~~~~~~~~~~~
compilation terminated.
Run Code Online (Sandbox Code Playgroud)

似乎 R 找不到名为libpq-fe.h. 解决这个问题的方法是什么?

Abe*_*ejo 8

事实证明,这可以通过安装 C 语言开发的库和头文件来解决。

百胜

yum install postgresql-devel
Run Code Online (Sandbox Code Playgroud)

易于

apt-get install libpq-dev
Run Code Online (Sandbox Code Playgroud)

参考:

  1. Amazon Web Services › 论坛 ›设置 pg gem - postgresql in development
  2. PostgreSQL › Yum 存储库 › postgresql-devel

  • 对于那些只使用 apt 的人:`sudo apt-get install libpq-dev`。祝你好运。 (4认同)