Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R:交互式RcppGSL使用_R_Makefile_Rcpp - Fatal编程技术网

R:交互式RcppGSL使用

R:交互式RcppGSL使用,r,makefile,rcpp,R,Makefile,Rcpp,我试图在64位Windows机器上使用RcppGSL,但感觉make变量的一些细微差别我不理解 以下是我尝试过的: 1.从二进制文件安装GSL,该二进制文件位于我在顶级R安装目录中创建的新目录中。 2.更新了环境变量以包含一个新变量LIB_GSL,该变量指向我解压缩GSL的文件夹。 3.在新目录中创建一组文件: -示例1.cpp -马克瓦尔斯·温 下面是每个文件的外观 例1.cpp example1.cpp文件是基本列规范函数,作为示例包含在RcppGSL包本身中: // [[Rcpp::dep

我试图在64位Windows机器上使用
RcppGSL
,但感觉
make
变量的一些细微差别我不理解

以下是我尝试过的:
1.从二进制文件安装GSL,该二进制文件位于我在顶级R安装目录中创建的新目录中。
2.更新了环境变量以包含一个新变量
LIB_GSL
,该变量指向我解压缩GSL的文件夹。
3.在新目录中创建一组文件:
-示例1.cpp
-马克瓦尔斯·温

下面是每个文件的外观

例1.cpp
example1.cpp
文件是基本列规范函数,作为示例包含在
RcppGSL
包本身中:

// [[Rcpp::depends(RcppGSL)]]
#include <RcppGSL.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>

// [[Rcpp::export]]
Rcpp::NumericVector colNorm(Rcpp::NumericMatrix sM) {

    RcppGSL::matrix<double> M(sM);   // create gsl data structures from SEXP
    int k = M.ncol();
    Rcpp::NumericVector n(k);       // to store results 

    for (int j = 0; j < k; j++) {
        RcppGSL::vector_view<double> colview = gsl_matrix_column (M, j);
        n[j] = gsl_blas_dnrm2(colview);
    }

    M.free();       // important: GSL wrappers use C structure
    return n;               // return vector  
}
问题: 但是,当我
sourceCpp
查看
example1.cpp
文件时,它会给出以下输出:

> Rcpp::sourceCpp('example53[RcppGSL].cpp')
g++ -m64 -I"F:/PROGRA~1/r/R-31~1.1/include" -DNDEBUG -IF:/programming/r/R-3.1.1/GSL/include     -I"F:/programming/r/R-3.1.1/library/Rcpp/include" -I"F:/programming/r/R-3.1.1/library/RcppGSL/include"  -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall  -mtune=core2 -c example53[RcppGSL].cpp -o example53[RcppGSL].o
g++ -m64 -shared -s -static-libgcc -o sourceCpp_9705.dll tmp.def example53[RcppGSL].o -LF:/programming/r/R-3.1.1/GSL/lib -lgsl -lgslcblas -LF:/PROGRA~1/r/R-31~1.1/bin/x64 -lRlapack -LF:/PROGRA~1/r/R-31~1.1/bin/x64 -lRblas -lgfortran -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LF:/PROGRA~1/r/R-31~1.1/bin/x64 -lR
f:/programming/r/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lgsl
f:/programming/r/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lgslcblas
collect2: ld returned 1 exit status
Error in Rcpp::sourceCpp("example53[RcppGSL].cpp") : 
  Error occurred building shared library.
现在,我知道我的文件实际上是
-L$(LIB\u GSL)/LIB/x64
,但链接器正在查找
-L$(LIB\u GSL)/LIB
(这也反映在我的
Makevars.win
中),因此无法找到
libgsl
libgslcblas
。我如何强制这是传递给
cppSource
PKG_LIBS
,而不是默认值


我目前的解决方法是将
-L$(LIB\u GSL)/LIB/x64
中的所有内容复制到
-L$(LIB\u GSL)/LIB
,但对该解决方案不满意

sourceCpp()不使用
Makevars.win

当我在Linux上执行此操作时,一切正常:

R> sourceCpp("/tmp/coln.cpp")   # where coln.cpp is what you have above
R> colNorm(matrix(1:16,4,4))
[1]  5.47723 13.19091 21.11871 29.08608
R> 
Windows上使用的内容是在包加载时通过包源中的文件
R/inline.R
确定的,它反映了
LIB\u GSL
的内容


也许行
gsl_libs是这样的,Windows二进制软件包没有源代码(可能是您让我查看“library/RcppGSL/R/”)。我将尝试下载源代码并进行编辑。另外,
install\u github(“eddelbuettel/rcppgsl”)
在Windows上出现了一个非常奇怪的错误;不要使用devtools,因为我有一个github repo。您也可以使用已发布的CRAN源,尽管现在似乎没有什么不同。
R> sourceCpp("/tmp/coln.cpp")   # where coln.cpp is what you have above
R> colNorm(matrix(1:16,4,4))
[1]  5.47723 13.19091 21.11871 29.08608
R>