安装“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)
编译好但无法成功加载包(作为构建时测试)。输出是这样的:
* 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/libarmadillo.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")
再次编译确定但现在无法加载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和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'
使用各种模式测试加载犰狳库的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没有加载犰狳库? 是否有R等价于LD_LIBRARY_PATH?
安装的其他软件包工作正常(约30个软件包)。
此外,armadillo C ++程序编译并运行正常:
#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
非常感谢,
答案 0 :(得分:3)
请注意,RcppArmadillo捆绑了Armadillo(它是一个仅限标头的库),因此使用RcppArmadillo.h
的客户端包将获得编译时所需的armadillo
部分 - 显式链接到预编译<{1}}库应该是不必要的。
armadillo
确实在某些已编译的代码(例如RcppArmadillo
)中使用armadillo
(来自其自己的包含标题)的部分,这些应该在fastLm
自己的RcppArmadillo
中发现共享对象文件RcppArmadillo.so
。
在我的OS X(El Capitan)计算机上,我在wrapper
符号上看不到ddot
前缀:
kevin:~/Library/R/3.2/library/RcppArmadillo/libs
$ nm RcppArmadillo.so | grep ddot
U _ddot_
有#define
,ARMA_USE_WRAPPER
,似乎可以控制这一点。选择的导出名称配置为:
https://github.com/RcppCore/RcppArmadillo/blob/master/inst/include/armadillo_bits/config.hpp#L46-L49
并在此处使用:
我认为您需要确保#define
未设置。你有可能在其他地方设置/配置吗?
答案 1 :(得分:0)
2年半后,问题再次出现,解决方案仍然有效且相关。 OSX中的R-3.4.3拒绝安装血腥的RcppArmadillo,除非我先通过port uninstall armadillo
删除armadillo系统包(不是R包)。
所以,
port uninstall armadillo
兄弟