R 安装包时找不到 GSL 库
我正在安装学术期刊补充材料中的软件包 (https://www.degruyter.com/document/doi/10.1515/snde-2012-0064/html?lang=en)。
我已经设置了 Windows 系统环境变量 LIB_GSL (作为“C:/R/local323”)和 PATHS (作为“C:/rtools40/bin/”、“C:/rtools/mingw64/bin”、“C:/ R/R-4.1.2/bin")
当我运行 install.packages("/cobreak_0.1.tar.gz", repos=NULL, type="source") 时,会发生这种情况
* installing *source* package 'cobreak' ...
** using staged installation
** libs
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11 -I"C:/R/R-4.1.2/include" -DNDEBUG -I'C:/Users/Phat/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Phat/Documents/R/win-library/4.1/RcppArmadillo/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cointmdl.cc -o cointmdl.o
In file included from genmdl.h:5,
from cointmdl.cc:1:
random_arma.h:4:10: fatal error: gsl/gsl_rng.h: No such file or directory
#include <gsl/gsl_rng.h>
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [C:/R/R-4.1.2/etc/x64/Makeconf:243: cointmdl.o] Error 1
ERROR: compilation failed for package 'cobreak'
我的猜测是问题出在 Makevars.win 文件中。这就是 Makevar 的样子
## This assume that we can call Rscript to ask Rcpp about its locations
## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = $(shell $(R_HOME)/bin/Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
更新: 我刚刚在这里链接发现了类似的问题。但是,按照说明进行操作后,我遇到了新的错误。这次是 boost 的问题
** libs
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/R/R-4.1.2/include" -DNDEBUG -IC:/R/local323/include -I. -I../inst/include -I'C:/Users/Phat/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Phat/Documents/R/win-library/4.1/RcppArmadillo/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cointmdl.cc -o cointmdl.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/R/R-4.1.2/include" -DNDEBUG -IC:/R/local323/include -I. -I../inst/include -I'C:/Users/Phat/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Phat/Documents/R/win-library/4.1/RcppArmadillo/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cpp_r_interface.cc -o cpp_r_interface.o
cpp_r_interface.cc:2:10: fatal error: boost/ptr_container/ptr_vector.hpp: No such file or directory
#include <boost/ptr_container/ptr_vector.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
,我尝试安装“BH”包,但问题仍然存在。
有人对如何解决这个问题有任何想法吗?
I am installing a package from the Supplementary materials of an academic journal (https://www.degruyter.com/document/doi/10.1515/snde-2012-0064/html?lang=en).
I've set the Windows system environment variables LIB_GSL (as "C:/R/local323") and PATHS (as "C:/rtools40/bin/", "C:/rtools/mingw64/bin", "C:/R/R-4.1.2/bin")
When I run install.packages("/cobreak_0.1.tar.gz", repos=NULL, type="source"), this happens
* installing *source* package 'cobreak' ...
** using staged installation
** libs
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11 -I"C:/R/R-4.1.2/include" -DNDEBUG -I'C:/Users/Phat/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Phat/Documents/R/win-library/4.1/RcppArmadillo/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cointmdl.cc -o cointmdl.o
In file included from genmdl.h:5,
from cointmdl.cc:1:
random_arma.h:4:10: fatal error: gsl/gsl_rng.h: No such file or directory
#include <gsl/gsl_rng.h>
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [C:/R/R-4.1.2/etc/x64/Makeconf:243: cointmdl.o] Error 1
ERROR: compilation failed for package 'cobreak'
My guess is the issue was in the Makevars.win file. This is what the Makevars looks like
## This assume that we can call Rscript to ask Rcpp about its locations
## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = $(shell $(R_HOME)/bin/Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
Update:
I just found a similar problem here link. However, after following the instruction, I encounter a new error. This time it's a problem with boost
** libs
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/R/R-4.1.2/include" -DNDEBUG -IC:/R/local323/include -I. -I../inst/include -I'C:/Users/Phat/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Phat/Documents/R/win-library/4.1/RcppArmadillo/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cointmdl.cc -o cointmdl.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/R/R-4.1.2/include" -DNDEBUG -IC:/R/local323/include -I. -I../inst/include -I'C:/Users/Phat/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Phat/Documents/R/win-library/4.1/RcppArmadillo/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cpp_r_interface.cc -o cpp_r_interface.o
cpp_r_interface.cc:2:10: fatal error: boost/ptr_container/ptr_vector.hpp: No such file or directory
#include <boost/ptr_container/ptr_vector.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
I tried to install the "BH" package but the problem still persists.
Does anyone have any ideas on how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我下载了你引用的 zip 存档并将其解压。它包含一个 R
cobreak_0.1.tar.gz
乍一看似乎很合理:但是,当我尝试将它安装到我的 Linux 系统上时,它遇到了函数
sympd() 的问题
已调用但未定义:从根本上讲,我不明白您为什么在 StackOverflow 上问这个问题。这是已发表并经过同行评审的作品,并且您会获得作者的姓名和地址(或者如果您必须是期刊编辑)。我会联系他们。
编辑 事实证明,这是由于“过时”的软件包源造成的,CRAN 存档会对此进行更改。正如犰狳文档所示,
inv(sympd(...))
不再可用,但inv_sympd()
可用。在两行中进行更改允许构建和安装包。对我来说没有问题:编辑2:我应该补充一点,该包实际上确实具有未声明的依赖项,例如,如果想要与 GNU GSL 链接(即由包提供的系统库
libgsl-dev (我是 Debian 维护者,但这是一个侧面细节))以及您注意到的 Boost 头文件的一个包含内容。总而言之,这反映了 SNDE 期刊的糟糕状况,编辑们应该执行更严格的再现性规则。这些现在更加常见,部分归功于 JStatSoft(我在其中担任副编辑)等期刊的领导,但旧论文的情况并非总是如此。无论如何:您可以构建这个包,您“只”需要学习如何在 Windows 上使用 GSL,这在 Windows 上的 R 支持材料中进行了记录。
So I downloaded the zip archive you referenced unpacked it. It contains an R
cobreak_0.1.tar.gz
which at first glance looks reasonable:However, when I try to install it on my Linux system it hits a wall over a function
sympd()
called but not defined:Fundamentally, I do not understand why you asked this question at StackOverflow. This is published and peer-reviewed work, and you are given a name and address of an author (or if you must a journal editor). I would contact them.
Edit Turns out this is due to 'stale' package sources, a CRAN archive would have that changed. As the documentation for Armadillo shows, the
inv(sympd(...))
is no longer available butinv_sympd()
. Making that change on two lines allows the package to build and install. No issues for me:Edit 2: I should add that the package does in fact have undeclared dependencies, for example if wants to link with GNU GSL (i.e. the system library provided for example by the package
libgsl-dev
on the Ubuntu system I use (and for which I am the Debian maintainer, but that is a side detail)) as well as the one inclusion of the Boost header file you noticed. So in sum this reflects poor on the SNDE journal where editors should have enforced stricter reproducibility rules. These are more common now, thanks in part due to leadership by journals such as JStatSoft (where I help as an Associate Editor) but that was not always the case with older papers. Anyway: you can build this package, you "just" need to learn how to use the GSL on Windows which is documented in the support material for R on Windows.