Mac OS X 11.6 (Big Bur) 上 RInside 的链接错误:找不到 pcre2-8 库

Linking error for RInside on Mac OS X 11.6 (Big Bur): pcre2-8 library not found

这可能是安装 PCRE2 时出错(我使用“sudo port install pcre2”),但是当我为 RInside “制作”示例代码时,我得到:

$ make rinside_sample0
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include   rinside_sample0.cpp   -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -L/usr/local/lib -lpcre2-8 -llzma -lbz2 -lz -licucore -ldl -lm -liconv  -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/Library/Frameworks/R.framework/Resources/lib -lRlapack  /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/lib/libRInside.a -o rinside_sample0
In file included from rinside_sample0.cpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include/RInside.h:26:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include/RInsideCommon.h:38:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:57:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data'
      [-Wunused-variable]
            SEXP data = Parent::get__();
                 ^
1 warning generated.
ld: library not found for -lpcre2-8
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [rinside_sample0] Error 1
$

德克,谢谢你的评论。你让我指出了正确的方向。我有两个旧版本的代码:pcre2 和 Rcpp。

我按照此处的说明安装了最新版本的“pcre2”:https://izziswift.com/how-to-install-pcre-development-headers-on-mac-osx/

我下载了“pcre”10.39 版,cd 到那个目录,运行:

./configure
make
make install

之后编译了RInside中的例子,但是出现运行时错误:

$ ./rinside_sample0
Error: function 'Rcpp_precious_remove' not provided by package 'Rcpp'
Execution halted
$

一些搜索显示错误来自 运行 旧版本 (1.0.6) 的“Rcpp”。我进入 RStudio,输入“install.packages("Rcpp")”更新到版本 1.0.7,现在一切都运行了!

希望完成这些步骤会对遇到这些问题的其他人有所帮助。