安装 R 包期间未定义对 `gsl_sf_lnfact' 的引用

问题描述 投票:0回答:1

伙计们,我正在尝试安装一个名为

MotifDiverge
的 R,它依赖于
rphast
MotifDb
IRanges
Rcpp
RcppGSL
RcppArmadillo
。我已经安装了所有这些依赖项。但安装过程中出了点问题。我是
gsl
Rtools
的新手,不知道该怎么办,希望有人给一些建议,非常感谢!

这是错误报告:

> library(BiocGenerics)

载入程辑包:‘BiocGenerics’

The following objects are masked from ‘package:stats’:

    IQR, mad, sd, var, xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find, get,
    grep, grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
    rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which.max, which.min

Warning message:
R graphics engine version 15 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed. 
> library(Biostrings)
载入需要的程辑包:S4Vectors
载入需要的程辑包:stats4

载入程辑包:‘S4Vectors’

The following objects are masked from ‘package:base’:

    expand.grid, I, unname

载入需要的程辑包:IRanges

载入程辑包:‘IRanges’

The following object is masked from ‘package:grDevices’:

    windows

载入需要的程辑包:XVector
载入需要的程辑包:GenomeInfoDb

载入程辑包:‘Biostrings’

The following object is masked from ‘package:base’:

    strsplit

> #library(rphast)
> library(MotifDb)
载入需要的程辑包:GenomicRanges
See system.file("LICENSE", package="MotifDb") for use restrictions.
> library(devtools)
载入需要的程辑包:usethis
Warning messages:
1: 程辑包‘devtools’是用R版本4.2.3 来建造的 
2: 程辑包‘usethis’是用R版本4.2.3 来建造的 
> library(rphast)

载入程辑包:‘rphast’

The following object is masked from ‘package:Biostrings’:

    complement

> library(Rcpp)
Warning message:
程辑包‘Rcpp’是用R版本4.2.3 来建造的 
> library(RcppGSL)

载入程辑包:‘RcppGSL’

The following object is masked from ‘package:Rcpp’:

    LdFlags

Warning message:
程辑包‘RcppGSL’是用R版本4.2.3 来建造的 
> library(RcppArmadillo)
Registered S3 methods overwritten by 'RcppArmadillo':
  method               from   
  predict.fastLm       RcppGSL
  print.fastLm         RcppGSL
  summary.fastLm       RcppGSL
  print.summary.fastLm RcppGSL

载入程辑包:‘RcppArmadillo’

The following objects are masked from ‘package:RcppGSL’:

    fastLm, fastLmPure

Warning message:
程辑包‘RcppArmadillo’是用R版本4.2.3 来建造的 
> library(gsl)
> install.packages("motifDiverge_0.4.12.tar.gz", repos=NULL, type="source")
将程序包安装入‘C:/Users/zhang/AppData/Local/R/win-library/4.2’
(因为‘lib’没有被指定)
* installing *source* package 'motifDiverge' ...
** using staged installation

   **********************************************
   WARNING: this package has a configure script
         It probably needs manual configuration
   **********************************************


** libs
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG  -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/Rcpp/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppGSL/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppArmadillo/include'   -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG  -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/Rcpp/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppGSL/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppArmadillo/include'   -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c rcpp_binom-rec.cpp -o rcpp_binom-rec.o
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG  -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/Rcpp/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppGSL/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppArmadillo/include'   -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c rcpp_convolve.cpp -o rcpp_convolve.o
rcpp_convolve.cpp: In function 'arma::vec rcpp_convolve(SEXP, SEXP)':
rcpp_convolve.cpp:18:6: warning: unused variable 'nx' [-Wunused-variable]
   18 |  int nx = x.n_elem ;
      |      ^~
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG  -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/Rcpp/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppGSL/include' -I'C:/Users/zhang/AppData/Local/R/win-library/4.2/RcppArmadillo/include'   -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c rcpp_p-sym.cpp -o rcpp_p-sym.o
g++ -std=gnu++11 -shared -s -static-libgcc -o motifDiverge.dll tmp.def RcppExports.o rcpp_binom-rec.o rcpp_convolve.o rcpp_p-sym.o -LC:/PROGRA~1/R/R-42~1.2/bin/x64 -lRlapack -LC:/PROGRA~1/R/R-42~1.2/bin/x64 -lRblas -lgfortran -lm -lquadmath -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-42~1.2/bin/x64 -lR
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: rcpp_binom-rec.o:rcpp_binom-rec:(.text+0x2c4): undefined reference to `gsl_ran_binomial_pdf'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: rcpp_p-sym.o:rcpp_p-sym.cpp:(.text+0x3cb): undefined reference to `gsl_sf_lnfact'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: rcpp_p-sym.o:rcpp_p-sym.cpp:(.text+0x429): undefined reference to `gsl_sf_lnfact'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: rcpp_p-sym.o:rcpp_p-sym.cpp:(.text+0x43d): undefined reference to `gsl_sf_lnfact'
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'motifDiverge'
* removing 'C:/Users/zhang/AppData/Local/R/win-library/4.2/motifDiverge'
Warning in install.packages :
  安装程序包‘motifDiverge_0.4.12.tar.gz’时退出狀態的值不是0

我已按照此处的说明在我的计算机上安装

gsl
https://solarianprogrammer.com/2020/01/26/getting-started-gsl-gnu-scientific-library-windows-macos-linux/ 我猜这个错误可能是因为R无法识别本地下载的
gsl

r rcpp gsl rtools
1个回答
0
投票

修改了

Makevars.win
文件夹中的
\src
文件后安装顺利

# Makevars.win

CXX_STD = CXX11

GSL_LIBS = -L$(R_HOME)/lib -lgsl -lgslcblas

PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) $(LIBHGWR_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(GSL_LIBS)

之后包就安装成功了!

© www.soinside.com 2019 - 2024. All rights reserved.