C에서의 지식은 새로운 사용자로서 매우 제한적입니다. C에서 작성한 코드 중 R에서 사용해야하는 코드가 있습니다. "gsl_integration"라이브러리를 사용하려고합니다. GSL 라이브러리가 설치되지 않은 다른 사람들에게 코드를 전달해야하므로 "gsl_integration"라이브러리의 모든 기능과 종속성을 포함하는 "integration.h"파일을 만들었습니다. 나는GSL 라이브러리의 R - 심볼을 찾을 수 없습니다.
$ R CMD SHLIB code.c
를 사용하여 내 code.c 파일을 컴파일 할 수 있어요 이것은 내가 RI에서 "code.so"파일을 dyn.load 할 때 나는
-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
를 얻을 출력 수 다음 오류
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 방법에 문제가있는 것 같습니까? 그 문제를 어떻게 해결할 수 있습니까?
도움을 주셔서 감사합니다. 터미널에서 컴파일 할 때 라이브러리 위치를 포함시켜야합니까? 즉 R CMD SHLIB code.c -lib_loc? 이것은 다른 사람이 GSL 라이브러리를 설치해야한다는 것을 의미합니까? 아니면 코드에 필요한 모든 것을 갖게 될까요? – Thor6
네, 위치를 추가하려면'-L ... location ... -lgsl lgslblas'가 필요합니다. 이것은 컴퓨터와 컴퓨터, OS에 따라 다를 수 있습니다. 그래서 RcppGSL이'gsl-config '- 실제 라이브러리. –
감사합니다, 더크, 효과가있었습니다. "PKG_LIBS = -L/usr/gsl/lib -lgsl -lgslcblas -lm"줄을 사용하여 작업 디렉토리에 Makevars 파일을 추가했습니다. – Thor6