无法在Fedora 20上构建R软件包"png"

19
我正在尝试构建 R 软件包 png,存储库表示需要有可用的 libpng
我使用的是Linux Fedora 20版本。
看起来我已经安装了...
[root@localhost bin]# yum install libpng
Loaded plugins: langpacks, refresh-packagekit
Package 2:libpng-1.6.3-3.fc20.x86_64 already installed and latest version
Nothing to do

但当我尝试安装它时:

> install.packages("png")
Installing package into ‘/home/statquant/R/x86_64-redhat-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/png_0.1-7.tar.gz'
Content type 'application/x-gzip' length 24990 bytes (24 Kb)
opened URL
==================================================
downloaded 24 Kb

* installing *source* package ‘png’ ...
** package ‘png’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    `libpng-config --cflags` -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic  -c read.c -o read.o
/bin/sh: libpng-config: command not found
read.c:3:17: fatal error: png.h: No such file or directory
 #include <png.h>
                 ^
compilation terminated.
make: *** [read.o] Error 1
ERROR: compilation failed for package ‘png’
* removing ‘/home/statquant/R/x86_64-redhat-linux-gnu-library/3.0/png’

The downloaded source packages are in
        ‘/tmp/RtmpG5MjG9/downloaded_packages’
Warning message:
In install.packages("png") :
  installation of package ‘png’ had non-zero exit status

4
很多时候安装软件包需要开发包的支持。请尝试运行 yum install libpng-devel,然后再次尝试重新安装。 - Dason
你就是那个人!它起作用了。 - statquant
@Dason,随意将其作为答案。 - Roman Luštrik
@RomanLuštrik 我已经很久没有使用 Fedora 了,所以我不确定那是否是问题所在。不过我会将其移至答案中。 - Dason
也适用于我。我从源代码构建了R 2.15.3,虽然我有可以链接的libpng.so文件,但在PNG功能构建之前仍需要开发包。当configure完成时,在配置摘要中,您将看到它作为“其他功能”之一。我没有将其安装为“软件包”。 - Robert Casey
2个回答

42

对于某些R包,您需要相应的开发库才能成功安装R包。在您的情况下,这应该可以满足您的需求。

# Do the following in your terminal (not in an R session)
yum install libpng-devel

接下来,您应该能够安装R包。

# Do the following in the R console (during an R session)
install.packages("png")

16

我在Ubuntu(16.04)上遇到了同样的问题,使用以下方法解决:

sudo apt-get install libpng-dev

当我们使用非Fedora发行版时,对于OpenSUSE:只需打开YaST,检查已安装的libpng(在我的情况下是libpng16-16),并添加相应的-devel(在我的情况下是libpng16-devel)。之后,R安装软件包时就没有任何问题了。 - 4rj4n
我正在使用Linux Mint,这对我解决了问题 - 谢谢 :) - Tal Galili

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接