我的软件包无法安装在我的机器上或 travis-ci.org 上。CRAN 版本的唯一更新是我添加了一个小插图。我一直在关注Rcpp - package和R-packages的示例;编译后的代码。
\n\n该错误与之前的这些问题相关,但不是重复的。
\n\nldconfig,尽管也许我的问题与之相关。从包目录:
\n\n# Restarting R session...\n> Rcpp::compileAttributes()\n> devtools::document() # a similar error using devtools::install()\nUpdating imputeMulti documentation\nLoading imputeMulti\nRe-compiling imputeMulti\n\xe2\x94\x80 installing *source* package \xe2\x80\x98imputeMulti\xe2\x80\x99 ...\n ** using staged installation\n ** libs\n g++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -std=c++0x -c RcppExports.cpp -o RcppExports.o\n g++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -std=c++0x -c count_compare.cpp -o count_compare.o\n g++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -std=c++0x -c utilities_rcpp.cpp -o utilities_rcpp.o\n g++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o imputeMulti.so RcppExports.o count_compare.o utilities_rcpp.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation\n installing to /private/var/folders/6h/px5b6ds15b72srhkxc42k9drt2vmnc/T/Rtmpa4w8vb/devtools_install_876345d52e22/00LOCK-imputeMulti/00new/imputeMulti/libs\n ** checking absolute paths in shared objects and dynamic libraries\n\xe2\x94\x80 DONE (imputeMulti)\nError in dyn.load(dllfile) : \n unable to load shared object \'./imputeMulti/src/imputeMulti.so\':\n dlopen(./imputeMulti/src/imputeMulti.so, 6): Symbol not found: _imputeMulti_supDistC\n Referenced from: ./imputeMulti/src/imputeMulti.so\n Expected in: flat namespace\n in ./imputeMulti/src/imputeMulti.so\nRun Code Online (Sandbox Code Playgroud)\n\n和会话信息:
\n\n> sessionInfo()\nR version 3.6.3 (2020-02-29)\nPlatform: x86_64-apple-darwin15.6.0 (64-bit)\nRunning under: macOS Mojave 10.14.6\n\nMatrix products: default\nBLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib\nLAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib\n\nlocale:\n[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nloaded via a namespace (and not attached):\n [1] Rcpp_1.0.4.6 compiler_3.6.3 prettyunits_1.1.1 remotes_2.1.1 tools_3.6.3 bit_1.1-15.2 \n [7] testthat_2.3.2 digest_0.6.25 pkgbuild_1.0.7 pkgload_1.0.2 RSQLite_2.2.0 memoise_1.1.0 \n[13] rlang_0.4.6 DBI_1.1.0 cli_2.0.2 rstudioapi_0.11 parallel_3.6.3 xfun_0.13 \n[19] withr_2.2.0 stringr_1.4.0 roxygen2_7.1.0 knitr_1.28 xml2_1.3.2 vctrs_0.2.4 \n[25] desc_1.2.0 fs_1.4.1 gtools_3.8.2 devtools_2.3.0 bit64_0.9-7 rprojroot_1.3-2 \n[31] glue_1.4.0 R6_2.4.1 processx_3.4.2 fansi_0.4.1 imputeMulti_0.7.1 sessioninfo_1.1.1\n[37] blob_1.2.1 callr_3.4.3 purrr_0.3.4 magrittr_1.5 backports_1.1.6 ps_1.3.2 \n[43] ellipsis_0.3.0 usethis_1.6.0 assertthat_0.2.1 stringi_1.4.6 crayon_1.3.4 \n\n> devtools::build() # works \nRun Code Online (Sandbox Code Playgroud)\n\n我的包:imputeMulti
\n\n我有以下 C++ 文件src/
# utilities_rcpp.cpp\n#include <Rcpp.h>\nusing namespace Rcpp;\n\n<two minor functions>\n\n# count_compare.cpp\n#include <Rcpp.h>\nusing namespace Rcpp;\n\n<one minor function>\nRun Code Online (Sandbox Code Playgroud)\n\n我也有
\n\n# imputeMulti-package.R\n## usethis namespace: start\n#\' @importFrom Rcpp sourceCpp, evalCpp\n## usethis namespace: end\nNULL\n\n#\' @useDynLib imputeMulti\n\n.onUnload <- function (libpath) {\n library.dynam.unload(\'imputeMulti\', libpath)\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我最好的猜测是该错误与 Q36952571 有关,但我不确定如何解决。任何帮助将不胜感激。
\n快速戳了一下,我认为您的包裹已损坏。
\n\n安装步骤失败
\n\n** testing if installed package can be loaded from temporary location\nError: package or namespace load failed for \xe2\x80\x98imputeMulti\xe2\x80\x99 in dyn.load(file, DLLpath = DLLpath, ...):\n unable to load shared object \'/usr/local/lib/R/site-library/00LOCK-imputeMulti/00new/imputeMulti/libs/imputeMulti.so\':\n /usr/local/lib/R/site-library/00LOCK-imputeMulti/00new/imputeMulti/libs/imputeMulti.so: undefined symbol: imputeMulti_supDistC\nError: loading failed\nExecution halted\nERROR: loading failed\n* removing \xe2\x80\x98/usr/local/lib/R/site-library/imputeMulti\xe2\x80\x99\nWarning message:\nIn install.packages(pkgs = f, lib = lib, repos = if (isMatchingFile(f)) NULL else repos) :\n installation of package \xe2\x80\x98imputeMulti_0.7.1.tar.gz\xe2\x80\x99 had non-zero exit status\nedd@rob:/tmp/imputeMulti(master)$\nRun Code Online (Sandbox Code Playgroud)\n\n也就是说,我们错过了您所说的一个符号imputeMulti_supDistC,而您做错了。使用 Rcpp 及其(很棒),compileAttributes()您无需调用.Call()这里那样您调用提供 R 包装器。
你犯了两次这个错误,这解决了它:
\n\nedd@rob:/tmp/imputeMulti(master)$ git diff R/int-count_levels.R\ndiff --git a/R/int-count_levels.R b/R/int-count_levels.R\nindex a4ce4cc..9e749cc 100755\n--- a/R/int-count_levels.R\n+++ b/R/int-count_levels.R\n@@ -4,7 +4,8 @@\n # wrapper to supDistC to move error checking outside of C++\n supDist <- function(x,y) {\n if (length(x) != length(y)) stop("Length of x and y differ.")\n- .Call(\'imputeMulti_supDistC\', PACKAGE = \'imputeMulti\', x, y)\n+ #.Call(\'imputeMulti_supDistC\', PACKAGE = \'imputeMulti\', x, y)\n+ supDistC(x, y)\n }\n\n # convert a factor-vector to an integer vector, where the integers correspond\n@@ -91,7 +92,8 @@ mx_my_compare <- function(mat_x, mat_y) {\n mat_y <- do.call("cbind", lapply(mat_y, fact_to_int))\n\n ## 1. Run code in C\n- .Call(\'imputeMulti_xy_compare\', PACKAGE = \'imputeMulti\', mat_x, mat_y)\n+ #.Call(\'imputeMulti_xy_compare\', PACKAGE = \'imputeMulti\', mat_x, mat_y)\n+ xy_compare(mat_x, mat_y)\n # mat_to_mat_compare(mat_x, mat_y, na.rm= TRUE)\n }\n\nedd@rob:/tmp/imputeMulti(master)$ \nRun Code Online (Sandbox Code Playgroud)\n\n进行这些简化,运行compileAttributes()以更新这两个RcppExports文件,然后就高兴了。
| 归档时间: |
|
| 查看次数: |
1254 次 |
| 最近记录: |