R无法识别GSL库未定义的引用 [英] R not recognizing GSL library undefined references

查看:119
本文介绍了R无法识别GSL库未定义的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在R中从github安装一个软件包(链接在这里: https://github.com/aliceyiwang/ mvabund ),使用devtools。我已经按照另一个软件包的说明安装了Rtools(在这里: https://cran.r-project.org/web/packages/dynr/vignettes/InstallationForUsers.pdf ),那里的所有检查都表明GSL和RTools已正确安装。

I am installing a package from github in R (link here: https://github.com/aliceyiwang/mvabund), using devtools. I have installed Rtools, using the instructions for another package (here: https://cran.r-project.org/web/packages/dynr/vignettes/InstallationForUsers.pdf) and all the checks there indicate that GSL and RTools are installed properly.

我已经设置了Windows系统环境变量LIB_GSL(如 C:/ R / local323 )和PATHS(如 C:/ RTools / bin /, C:/ RTools / mingw_64 / bin, C:/R/R-3.5.1/bin

I've set the Windows system environment variables LIB_GSL (as "C:/R/local323") and PATHS (as "C:/RTools/bin/", "C:/RTools/mingw_64/bin", "C:/R/R-3.5.1/bin")

在安装软件包之前,我还在R中运行以下代码:

I also run the following code in R before installing the package:

Sys.setenv("LIB_GSL" = "C:/R/local323")
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")
Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:/RTools/bin/",
                        "C:/RTools/mingw_64/bin", "C:/R/R-3.5.1/bin", sep = ";"))

问题:

何时我运行:

devtools::install_github("aliceyiwang/mvabund")

代码可以很好地启动并开始安装软件包。但是,当发生这种情况时,有一点很重要:

The code initiates well and starts installing the package. There comes a point, however, when this happens:

[...excluded very long list of undefined references like that below...]
summary.o:summary.cpp:(.text+0x194c): undefined reference to `gsl_vector_free'
    collect2.exe: error: ld returned 1 exit status
    no DLL was created
    ERROR: compilation failed for package 'mvabund'
    * removing 'C:/R/R-3.5.1/library/mvabund'
    In R CMD INSTALL
    Error in i.p(...) : 
      (converted from warning) installation of package ‘C:/Users/Joshua/AppData/Local/Temp/RtmpsPp5oY/file2154340c11f8/mvabund_4.0.tar.gz’ had non-zero exit status

我的猜测是在某个地方,通往这些功能的某些路径未正确定义。我究竟做错了什么?

My guess is that somewhere, some path to those functions has not been defined properly. What am I doing wrong?

我的会话信息是

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] usethis_1.4.0  devtools_2.0.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        rstudioapi_0.8    magrittr_1.5      pkgload_1.0.2     R6_2.3.0          rlang_0.3.0.1    
 [7] tools_3.5.1       pkgbuild_1.0.2    sessioninfo_1.1.1 cli_1.0.1         withr_2.1.2       remotes_2.0.2    
[13] yaml_2.2.0        assertthat_0.2.0  digest_0.6.18     rprojroot_1.3-2   crayon_1.3.4      processx_3.2.1   
[19] callr_3.1.0       fs_1.2.6          ps_1.2.1          curl_3.2          testthat_2.0.1    memoise_1.1.0    
[25] glue_1.3.0        compiler_3.5.1    desc_1.2.0        backports_1.1.2   prettyunits_1.0.2
> 


推荐答案

我将包括整个答案问题,因为它在任何地方都不存在,可以解决此问题以及该问题中的错误:

I'm going to include the entire answer to this problem, since it exists nowhere else in one spot, which fixes the errors in this question, and in this one: Installing R package from github returns non-zero exit status error; GSL and Rtools correctly installed

在执行任何操作之前,请确保R未安装在文件名中带有空格的位置。例如,我们不想要C:\Program Files\R,因为它有一个空格,并且众所周知,死亡机器人可以使用这些空格,这会破坏您的安装。

Before doing anything, make sure that R is not installed into a location with spaces in the file name. For example, we don't want C:\Program Files\R, because that has a space, and, as we all know, spaces let in the death bots, which destroy your installation.

然后安装RTools(并且在安装RTools时:文件名中没有空格...可能要花一些时间来安装)和GSL库,请严格按照Windows的说明进行操作:

Then install RTools (and, when you install RTools: no spaces in the file name... may take a while to install) and the GSL libraries following VERY CLOSELY the Windows instructions here:

https: //cran.r-project.org/web/packages/dynr/vignettes/InstallationForUsers.pdf

(R的GSL库在这里:
http://www.stats.ox.ac.uk/pub /Rtools/libs.html
Rtools此处-下载最新的冻结版本(目前:Rtools34.exe):
https://cran.r-project.org/bin/windows/Rtools/

(GSL libraries for R here: http://www.stats.ox.ac.uk/pub/Rtools/libs.html Rtools here - download the latest Frozen version (for now: Rtools34.exe): https://cran.r-project.org/bin/windows/Rtools/)

然后我们从 https://github.com/aliceyiwang/mvabund 下载该软件包的压缩副本。 a>
并将其解压缩到我们的工作目录中。

Then we download a zipped copy of the package from https://github.com/aliceyiwang/mvabund and unzip it in our working directory.

现在,使用上述安装方法,GSL库位于两个文件夹中,一个用于i386和x64体系结构。不幸的是,没有设置mvabund github版本中的Makevars.win文件来区分该设置中的体系结构,因为它只有一个PKG_LIBS路径。

Now, using the above installation method, the GSL libraries are in two folders, one for each of the i386 and x64 architectures. Unfortunately, the Makevars.win file in the mvabund github version is not set up to distinguish between the architectures in that setup, as it has only one path for PKG_LIBS.

所以,清除Makevars.win文件并将其替换为:

So, clear the Makevars.win file and replace it with:

## This assumes that the LIB_GSL variable points to working GSL libraries
CXX_STD = CXX11
ARCH=x64
ifeq "$(WIN)" "64"
ARCH= i386
else
ARCH= x64
endif
PKG_CPPFLAGS = -I$(LIB_GSL)/include -I. -I../inst/include
PKG_LIBS=-L"$(LIB_GSL)\lib"$(R_ARCH_BIN) -lgsl -lgslcblas 

然后我们运行以下代码。用您的文件路径替换文件路径。

Then we run the following code. Replace the file paths with your file paths.

Sys.setenv("LIB_GSL" = "C:/R/local323") # Replace file path here; this is the GSL library location, same as you specified for LIB_GSL in the windows environment 
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/") # Replace file path here
Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:/RTools/bin/", sep = ";")) # Replace file path here
Sys.setenv("PKG_LIBS"="-L$(LIB_GSL)/lib/$(R_ARCH_BIN) -lgsl -lgslcblas")
Sys.setenv("PKG_CPPFLAGS"="-I$(LIB_GSL)/include -I. -I../inst/include")

# this assumes you have unzipped the mvabund download in your working directory
file.rename("mvabund-master", "mvabund")
shell("R CMD build mvabund")
install.packages("mvabund_4.0.tar.gz", repos = NULL) #may need to replace file name
library("mvabund")

让我们进行分析,然后:

Let's run an analysis, then:

abund <- mvabund(dataset[,8:39]) #community matrix section of spreadsheet
treatment <- as.character(dataset$Treatment) #treatment variable
## pairwise comparison 
manyglm(abund ~ treatment) -> msolglm
anova(msolglm, pairwise.comp = treatment, nBoot = 9) #pairwise comparisons make it run longer

这篇关于R无法识别GSL库未定义的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆