作为新用户,我对C的知识非常有限,我有一些用C编写的代码需要在R中使用。我尝试使用“ gsl_integration”库。因为需要将代码传递给可能未安装GSL库的其他人,所以我创建了“ integration.h”文件,其中包含“ gsl_integration”库中的所有功能和依赖项。我可以使用编译我的code.c文件
$ R CMD SHLIB code.c
这是我得到的输出
-I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
-I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include
-fPIC -Wall -mtune=core2 -g -O2 -c code.c -o code.o
clang -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 code.so code.o
-F/Library/Frameworks/R.framework/..
-framework R -Wl,-framework -Wl,CoreFoundation
当我尝试在RI中dyn.load“ code.so”文件时,出现以下错误
Error in dyn.load("code.so") :
unable to load shared object '/Users/Thodoris/Desktop/Int_C/code.so':
dlopen(/Users/Thodoris/Desktop/Int_C/code.so, 6): Symbol not found: _gsl_integration_qags
Referenced from: /Users/Thodoris/Desktop/Int_C/code.so
Expected in: flat namespace
in /Users/Thodoris/Desktop/Int_C/code.so
我想R尝试找到库的方式有问题吗?有什么想法可以解决吗?
您没有链接到GSL。
您可能要模仿其设置的一个软件包是我的RcppZiggurat软件包,它可以执行以下操作:
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "RcppGSL:::LdFlags()"`
也就是说,它具有通过调用我的RcppGSL包返回正确的库位置的功能,该调用在包启动时就知道该位置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句