安装"RcppArmadillo“使我非常失败,现在在"R”上安装了几个小时
R-2.3.1和MACOS系统10.8.5:
Darwin 12.6.0 Darwin Kernel Version 12.6.0; xnu/RELEASE_X86_64 x86_64现已编译并成功安装了Armadillo (6.100.0)。
这就是罪犯:
R> install.packages("RcppArmadillo", verbose=T)编译OK,但未能成功加载包(作为构建时测试)。产出如下:
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
* checking LAPACK_LIBS: divide-and-conquer complex SVD available via R-supplied LAPACK
** libs
g++ -I/opt/local/R.framework/Resources/include -DNDEBUG -arch x86_64 -framework System -Wunused-command-line-argument-hard-error-in-future -I/opt/local/include -I/Users/.../usr/include -I/Users/.../usr/local/include -I/opt/X11/include -Wunused-command-line-argument-hard-error-in-future -I"/opt/local/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I../inst/include -fPIC -arch x86_64 -framework System -Wunused-command-line-argument-hard-error-in-future -I/opt/local/include -I/Users/.../usr/include -I/Users/.../usr/local/include -I/opt/X11/include -Wunused-command-line-argument-hard-error-in-future -c RcppArmadillo.cpp -o RcppArmadillo.o
clang: warning: -framework System: 'linker' input unused
clang: warning: -framework System: 'linker' input unused
g++ -I/opt/local/R.framework/Resources/include -DNDEBUG -arch x86_64 -framework System -Wunused-command-line-argument-hard-error-in-future -I/opt/local/include -I/Users/.../usr/include -I/Users/.../usr/local/include -I/opt/X11/include -Wunused-command-line-argument-hard-error-in-future -I"/opt/local/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I../inst/include -fPIC -arch x86_64 -framework System -Wunused-command-line-argument-hard-error-in-future -I/opt/local/include -I/Users/.../usr/include -I/Users/.../usr/local/include -I/opt/X11/include -Wunused-command-line-argument-hard-error-in-future -c RcppExports.cpp -o RcppExports.o
clang: warning: -framework System: 'linker' input unused
clang: warning: -framework System: 'linker' input unused
g++ -I/opt/local/R.framework/Resources/include -DNDEBUG -arch x86_64 -framework System -Wunused-command-line-argument-hard-error-in-future -I/opt/local/include -I/Users/.../usr/include -I/Users/.../usr/local/include -I/opt/X11/include -Wunused-command-line-argument-hard-error-in-future -I"/opt/local/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I../inst/include -fPIC -arch x86_64 -framework System -Wunused-command-line-argument-hard-error-in-future -I/opt/local/include -I/Users/.../usr/include -I/Users/.../usr/local/include -I/opt/X11/include -Wunused-command-line-argument-hard-error-in-future -c fastLm.cpp -o fastLm.o
clang: warning: -framework System: 'linker' input unused
clang: warning: -framework System: 'linker' input unused
g++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/R.framework/Resources/lib -arch x86_64 -framework System -Wunused-command-line-argument-hard-error-in-future -L/opt/local/lib -L/Users/.../usr/lib -L/Users/.../usr/lib -L/opt/X11/lib -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -L/opt/local/R.framework/Resources/lib -lRlapack -L/opt/local/R.framework/Resources/lib -lRblas -F/opt/local/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
installing to /opt/local/R.framework/Versions/3.2/Resources/library/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/opt/local/R.framework/Versions/3.2/Resources/library/RcppArmadillo/libs/RcppArmadillo.so':
dlopen(/opt/local/R.framework/Versions/3.2/Resources/library/RcppArmadillo/libs/RcppArmadillo.so, 6): Symbol not found: _wrapper_ddot_
Referenced from: /opt/local/R.framework/Versions/3.2/Resources/library/RcppArmadillo/libs/RcppArmadillo.so
Expected in: flat namespace
in /opt/local/R.framework/Versions/3.2/Resources/library/RcppArmadillo/libs/RcppArmadillo.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/opt/local/R.framework/Versions/3.2/Resources/library/RcppArmadillo’因此,简而言之,它需要符号"_wrapper_ddot_“,这是它找不到的。但是这个符号在/opt/local/lib/libarmadyar.6.dylib中,该符号已成功安装。例如:
命令:
nm /opt/local/lib/libarmadillo.6.dylib | grep _wrapper_ddot_产出:
/opt/local/lib/libarmadillo.6.dylib
00000000000023e0 T _wrapper_ddot_然后创建一个~/.R/Makevars,其中包含:
PKG_LIBS += -L/opt/local/lib -larmadillo尝试使用以下方法再次安装:
R> install.packages("RcppArmadillo")再次编译OK,但现在它无法加载armadillo dylib,并给出以下错误消息:
...
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/private/tmp/RtmpqEsodh/Rinst62b64deb7e7/RcppArmadillo/libs/RcppArmadillo.so':
dlopen(/private/tmp/RtmpqEsodh/Rinst62b64deb7e7/RcppArmadillo/libs/RcppArmadillo.so, 6): Library not loaded: libarmadillo.6.dylib
Referenced from: /private/tmp/RtmpqEsodh/Rinst62b64deb7e7/RcppArmadillo/libs/RcppArmadillo.so
Reason: image not found
Error: loading failed我甚至手动编译了包,跳过测试,然后安装。不是的!它总是抱怨说它无法加载鲤鱼库或找不到符号"_wrapper_ddot_“。
然而,(依赖)鲤鱼库是存在的:
ls -al /opt/local/lib/libarmadillo.6.10.0.dylib
-rwxr-xr-x 1 root admin 5... /opt/local/lib/libarmadillo.6.10.0.dylib(以及与它的各种符号链接,例如6.dylib和just dylib)
将~/.R/Makevars设置为:
PKG_LIBS += -larmadillo
CFLAGS += ${PKG_LIBS}
CXXFLAGS += ${PKG_LIBS}从这方面没有带来好消息(我现在很绝望)。
最后,我编写了一个小的c程序,用于dlopen() armadillo库(dylib)。取决于我使用它的模式是成功还是失败,如下所示:
trying : mode 2 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 2 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 1 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 1 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 8 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 8 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 4 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 4 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 18 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
error for mode 18 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib' err: Undefined error: 0
trying : mode 17 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
error for mode 17 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib' err: Undefined error: 0
trying : mode 24 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
error for mode 24 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib' err: Undefined error: 0
trying : mode 20 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
error for mode 20 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib' err: Undefined error: 0
trying : mode 130 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 130 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 129 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 129 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 136 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 136 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 132 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 132 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 258 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 258 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 257 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 257 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 264 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 264 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
trying : mode 260 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'
success: mode 260 and lib '/opt/local/lib/libarmadillo.6.10.0.dylib'使用各种模式测试加载armadillo库的C程序是:
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <dlfcn.h>
int main(void){
char lib[] = "/opt/local/lib/libarmadillo.6.10.0.dylib";
int modes[] = {
RTLD_NOW, RTLD_LAZY, RTLD_GLOBAL, RTLD_LOCAL,
RTLD_NOW|RTLD_NOLOAD, RTLD_LAZY|RTLD_NOLOAD, RTLD_GLOBAL|RTLD_NOLOAD, RTLD_LOCAL|RTLD_NOLOAD,
RTLD_NOW|RTLD_NODELETE, RTLD_LAZY|RTLD_NODELETE, RTLD_GLOBAL|RTLD_NODELETE, RTLD_LOCAL|RTLD_NODELETE,
RTLD_NOW|RTLD_FIRST, RTLD_LAZY|RTLD_FIRST, RTLD_GLOBAL|RTLD_FIRST, RTLD_LOCAL|RTLD_FIRST
};
for(int modeI=0;modeI<16;modeI++){
int mode = modes[modeI];
void *ahandle;
printf("trying : mode %d and lib '%s'\n", mode, lib);
if( (ahandle=dlopen(lib, mode)) == NULL ){
fprintf(stderr, "\terror for mode %d and lib '%s'", mode, lib);
printf("\terr: %s\n", strerror(errno));
} else {
dlclose(ahandle);
printf("\tsuccess: mode %d and lib '%s'\n", mode, lib);
}
}
}问题是:为什么R不加载armadillo库?是否有一个与LD_LIBRARY_PATH等价的R?
其他软件包安装正常(大约30个软件包)。
此外,armadillo C++程序编译并运行OK:
#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;
int main(int argc, char** argv)
{
mat A = randu<mat>(4,5);
mat B = randu<mat>(4,5);
cout << A*trans(B) << endl;
return 0;
}使用
g++ -I/opt/local/include -L/opt/local/lib arma.c -larmadillo非常感谢,
发布于 2018-02-15 13:44:01
经过两年半的时间,该问题再次出现,解决方案仍然有效和相关。在OSX中,R-3.4.3拒绝安装血腥的RcppArmadillo,除非我首先通过port uninstall armadillo移除鲤鱼系统包(而不是R包)。
所以,
port uninstall armadillo
兄弟们
https://stackoverflow.com/questions/33291313
复制相似问题