c++ - 尝试使用RTools在R4.0上安装软件包时出现编译错误

标签 c++ r compiler-errors installation

我需要安装软件包“yags”以适合GEE。但是,我在安装过程中遇到了问题:代码返回错误。 (我正在使用R版本4.0.0(2020-04-24),平台:x86_64-w64-mingw32/x64(64位),并且还安装了RStudio和RTools的最新版本)

install.packages("yags", repos="http://R-Forge.R-project.org", type="source")

和错误:
** using staged installation
** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG          -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c yags.cc -o yags.o
yags.cc:2476:2: warning: "/*" within comment [-Wcomment]
  /* extern "C" {

yags.cc:2477:2: warning: "/*" within comment [-Wcomment]
  /* void democc( int* n, double* xin, double* xout )

yags.cc:2478:2: warning: "/*" within comment [-Wcomment]
  /*  {

yags.cc:2479:2: warning: "/*" within comment [-Wcomment]
  /*  matrix dumtim = transp(make_row(0.0,2.0,4.0,6.0));

yags.cc:2480:2: warning: "/*" within comment [-Wcomment]
  /*  matrix Xin = from_S(xin, *n, *n);

yags.cc:2481:2: warning: "/*" within comment [-Wcomment]
  /*  //set_el(Xin,0,0) = 491.3626;

yags.cc:2482:2: warning: "/*" within comment [-Wcomment]
  /*  matrix Z = LDLt(Xin);

yags.cc:2483:2: warning: "/*" within comment [-Wcomment]
  /*  //to_S(form_diag(extract_diag(Z)),xout);

yags.cc:2484:2: warning: "/*" within comment [-Wcomment]
  /*  //to_S(lowutri(Z),xout);

yags.cc:2485:2: warning: "/*" within comment [-Wcomment]
  /*  //matrix Ri = exinv(mat11(.5),3,mat11(0.));

yags.cc:2486:2: warning: "/*" within comment [-Wcomment]
  /*  matrix Ri = fominv(mat11(.5),4,dumtim);

yags.cc:2487:2: warning: "/*" within comment [-Wcomment]
  /*  matrix ZZ = diffL( exinv, mat11(.33333) , 4, dumtim, 0.000001 );

yags.cc:2488:2: warning: "/*" within comment [-Wcomment]
  /*

yags.cc:2489:2: warning: "/*" within comment [-Wcomment]
  /* GetUjStruc( dB, JJ, BB, fominv, mat11(.33333), 4, dumtim, .000001 )

yags.cc:2490:2: warning: "/*" within comment [-Wcomment]
  /*

yags.cc:2491:2: warning: "/*" within comment [-Wcomment]
  /*  to_S(JJ,xout);

yags.cc:2492:2: warning: "/*" within comment [-Wcomment]
  /*  }

yags.cc:2493:2: warning: "/*" within comment [-Wcomment]
  /* }  */

yags.cc: In function 'matrix transp(matrix)':
yags.cc:196:10: warning: variable 'look' set but not used [-Wunused-but-set-variable]
  double *look, *load;
          ^~~~
yags.cc: In function 'matrix operator/(matrix&, matrix&)':
yags.cc:472:7: warning: unused variable 'a2c' [-Wunused-variable]
   int a2c = arg2.cols();
       ^~~
yags.cc: In function 'matrix delete_col(matrix, int)':
yags.cc:558:6: warning: unused variable 'ncop' [-Wunused-variable]
  int ncop, nresel, skip;
      ^~~~
yags.cc:558:12: warning: unused variable 'nresel' [-Wunused-variable]
  int ncop, nresel, skip;
            ^~~~~~
yags.cc:558:20: warning: unused variable 'skip' [-Wunused-variable]
  int ncop, nresel, skip;
                    ^~~~
yags.cc:559:10: warning: unused variable 'resbase' [-Wunused-variable]
  double *resbase, *Xbase;
          ^~~~~~~
yags.cc:559:20: warning: unused variable 'Xbase' [-Wunused-variable]
  double *resbase, *Xbase;
                    ^~~~~
yags.cc: In function 'int split(matrix&, matrix&, matrix*)':
yags.cc:1223:12: warning: unused variable 'j' [-Wunused-variable]
  int i=0 , j=0 , k=0, start=0, end=0, len=1;
            ^
yags.cc: In function 'matrix* split(matrix&, matrix&)':
yags.cc:1258:12: warning: unused variable 'j' [-Wunused-variable]
  int i=0 , j=0 , k=0, start=0, end=0, len=1;
            ^
yags.cc: In function 'matrix mult_like_S(matrix, matrix)':
yags.cc:1576:11: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   if (nc1 == 1 & nc2 >= 1) { NC = nc2; confto2 = 1; }
       ~~~~^~~~
yags.cc:1577:16: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   else if (nc2 == 1 & nc1 >=1 ) {NC = nc1; confto2 = 0; }
            ~~~~^~~~
yags.cc: In function 'matrix UJ_equi_eval(matrix, matrix, matrix, double, int, matrix)':
yags.cc:2055:11: warning: unused variable 'rho' [-Wunused-variable]
    double rho = alpin.el(0,0);
           ^~~
yags.cc:2057:11: warning: unused variable 'dUdr' [-Wunused-variable]
    double dUdr = 0.;
           ^~~~
yags.cc: In function 'void yags_engine(int*, int*, int*, double*, double*, double*, double*, double*, double*, int*, double*, int*, int*, double*, double*, double*, double*, double*, double*, double*, double*, double*, int*, int*, double*, double*, int*, double*, double*, double*, double*, double*, double*, int*)':
yags.cc:2220:18: error: overloaded function with no contextual type information
     mu = (void *)exp;
                  ^~~
yags.cc:2221:24: error: overloaded function with no contextual type information
     dmu_deta = (void *)exp;
                        ^~~
yags.cc:2232:18: error: overloaded function with no contextual type information
     mu = (void *)exp;
                  ^~~
yags.cc:2233:24: error: overloaded function with no contextual type information
     dmu_deta = (void *)exp;
                        ^~~
yags.cc:2250:18: error: overloaded function with no contextual type information
     mu = (void *)exp;
                  ^~~
yags.cc:2251:24: error: overloaded function with no contextual type information
     dmu_deta = (void *)exp;
                        ^~~
yags.cc:2256:18: error: overloaded function with no contextual type information
     mu = (void *)exp;
                  ^~~
yags.cc:2257:24: error: overloaded function with no contextual type information
     dmu_deta = (void *)exp;
                        ^~~
yags.cc:2360:15: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    while (del > *tol & iter < *maxiter )
           ~~~~^~~~~~
yags.cc:2370:18: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
     if (*corcode == UJ_equimart | *fixscale == 1) phi = 1.0;
         ~~~~~~~~~^~~~~~~~~~~~~~
yags.cc:2334:8: warning: unused variable 'cc' [-Wunused-variable]
    int cc = Xin.cols();
        ^~
yags.cc:2275:12: warning: unused variable 'User_cor' [-Wunused-variable]
  const int User_cor = 9;
            ^~~~~~~~
yags.cc:2206:9: warning: statement will never be executed [-Wswitch-unreachable]
   printf("famco %d\n", *famcode);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [C:/PROGRA~1/R/R-40~1.0/etc/i386/Makeconf:227: yags.o] Error 1
ERROR: compilation failed for package 'yags'
* removing 'C:/Users/Morgane/Documents/R/win-library/4.0/yags'
Warning in install.packages :
  installation of package ‘yags’ had non-zero exit status


会有人知道可能出什么问题了吗?

我知道这个特定的软件包需要'multicore'作为依赖项,因此我尝试使用CRAN上的文件预先安装此软件包,但还会收到相同类型的错误消息:
install.packages("https://cran.r-project.org/src/contrib/Archive/multicore/multicore_0.1-1.tar.gz", repos=NULL, type="source")

错误:
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/Archive/multicore/multicore_0.1-1.tar.gz'
Content type 'application/x-gzip' length 12497 bytes (12 KB)
downloaded 12 KB

* installing *source* package 'multicore' ...
** using staged installation
** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"gcc  -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG          -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c fork.c -o fork.o
fork.c:13:10: fatal error: sys/select.h: No such file or directory
 #include <sys/select.h>
          ^~~~~~~~~~~~~~
compilation terminated.
make: *** [C:/PROGRA~1/R/R-40~1.0/etc/i386/Makeconf:222: fork.o] Error 1
ERROR: compilation failed for package 'multicore'
* removing 'C:/Users/Morgane/Documents/R/win-library/4.0/multicore'
Warning in install.packages :
  installation of package ‘C:/Users/Morgane/AppData/Local/Temp/Rtmp2rFgVC/downloaded_packages/multicore_0.1-1.tar.gz’ had non-zero exit status

最佳答案

这两个软件包不再是标准的R软件包,因此不能保证“最终用户”可以安装它们。 R-Forge是开发服务器,软件包“multicore”已存档。 CRAN suggests使用包并行代替。由于并行是基本软件包,因此它已经存在并且不需要安装。

然后,我们去打包 yags :查看R-Forge,我们发现

Version: 6.1-13 | Last change: 2011-04-27 05:07:10+02

所以它似乎已经过时了。因此,我建议您与原始的软件包作者联系,或者寻找替代的,可能是较新的实现,例如rjags或在网上搜索gee R cranjags R

关于c++ - 尝试使用RTools在R4.0上安装软件包时出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62173299/

相关文章:

c++ - 我实际上如何在捕获的一半图像上设置光流?

从 R 中的文档语料库中删除 "empty"字符项?

function - 有没有办法在 R 的函数中使用两个 '...' 语句?

r - 图片作为 Shiny 仪表板的背景

java - 意外绑定(bind)

c++ - 将指针传递给宏的省时方法

c++ - 当我使用 cout 显示输出时,为什么必须将按位运算符(例如 &、| 等)括在括号中?

c++ - 如何在不传递大量参数的情况下处理类的 "many small functions"的想法?

c++ - 编译器说它找不到文件,但在 "unfound"文件中报告错误?

c++ - undefined symbol SystemRuntimeMacOSX::Initialize 和 SystemRuntimeMacOSX::Terminate