RHmm归档包安装失败编译报错,咨询能否继续安装该包
RHmm_2.0.3安装失败问题
问题背景
我尝试从本地归档包RHmm_2.0.3.tar.gz安装R包,使用命令:
install.packages(path_to_file, repos=NULL, dependencies=TRUE)
编译报错信息
安装过程中出现编译错误,具体输出如下:
Installing package into ‘C:/Users/tars/AppData/Local/R/win-library/4.3’ (as ‘lib’ is unspecified) * installing *source* package 'RHmm' ... ** package 'RHmm' successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: 'G__~1.EXE (GCC) 12.2.0' g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -w -D_RDLL_ -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c Kmeans.cpp -o Kmeans.o .... .... cDMatrix.cpp:497:24: error: too few arguments to function 'void dspev_(const char*, const char*, const int*, double*, double*, double*, const int*, double*, int*, size_t, size_t)' .... cDMatrix.cpp:538:20: error: too few arguments to function 'void dspev_(const char*, const char*, const int*, double*, double*, double*, const int*, double*, int*, size_t, size_t)' .... make: *** [C:/PROGRA~1/R/R-43~1.0/etc/x64/Makeconf:272: cDMatrix.o] Error 1 ERROR: compilation failed for package 'RHmm' * removing 'C:/Users/tars/AppData/Local/R/win-library/4.3/RHmm' Warning in install.packages : installation of package ‘C:/Users/tars/Desktop/RHmm_2.0.3.tar.gz’ had non-zero exit status
疑问
这个包还能安装吗?还是已经彻底过时了?
当前会话信息
执行sessionInfo()的输出:
R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 Matrix products: default time zone: Europe/Kiev tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0
解决方案说明
报错根源是RHmm_2.0.3调用的dspev_函数(LAPACK线性代数库接口)参数数量不匹配。新版本LAPACK对该函数的参数要求有更新,但这个包的代码仍采用旧调用方式,和你当前R 4.3.0搭配的编译工具链(rtools43中的GCC 12.2.0)不兼容。
可行的安装尝试方向
- 降级R版本:选择和RHmm_2.0.3发布时间匹配的旧版R(比如R 3.6.x及更早),旧版R对应的编译工具链使用的LAPACK版本和包代码兼容,大概率能正常编译安装。
- 修改包源代码:解压
RHmm_2.0.3.tar.gz,找到cDMatrix.cpp文件,修改第497和538行的dspev_调用,补充缺失的两个size_t类型参数(通常传入1或对应参数的字节大小),修改后重新打包成tar.gz再尝试安装。 - 寻找预编译二进制包:如果能找到对应Windows系统的RHmm预编译二进制包(.zip格式),直接用
install.packages("path/to/RHmm.zip", repos=NULL, type="binary")安装,跳过编译步骤。
结论:这个包并非彻底过时,只是和新的R版本、编译工具链不兼容,通过上述方法仍有机会安装成功。
内容的提问来源于stack exchange,提问作者mr.T
相关产品推荐
相关产品推荐

